Exemplo n.º 1
0
func (v *VariableDecl) String() string {
	if v.Assignment == nil {
		return "(" + util.Blue("VariableDecl") + ": " + v.Variable.String() + ")"
	} else {
		return "(" + util.Blue("VariableDecl") + ": " + v.Variable.String() +
			" = " + v.Assignment.String() + ")"
	}
}
Exemplo n.º 2
0
func (v *Block) String() string {
	if len(v.Nodes) == 0 {
		return "(" + util.Blue("Block") + ": )"
	}

	result := "(" + util.Blue("Block") + ":\n"
	for _, n := range v.Nodes {
		result += "\t" + n.String() + "\n"
	}
	return result + ")"
}
Exemplo n.º 3
0
func (v *ImplDecl) String() string {
	var result string
	for _, decl := range v.Functions {
		result += "\t" + decl.String() + "\n"
	}
	return "(" + util.Blue("ImplDecl") + ": " + result + ")"
}
Exemplo n.º 4
0
func (v *EnumDecl) String() string {
	result := "\n"
	for _, val := range v.Body {
		result += "\t" + val.String() + "\n"
	}
	return "(" + util.Blue("EnumDecl") + ": " + result + ")"
}
Exemplo n.º 5
0
func (v *ArrayLiteral) String() string {
	res := "(" + util.Blue("ArrayLiteral") + ":"
	for _, mem := range v.Members {
		res += " " + mem.String()
	}
	return res + ")"
}
Exemplo n.º 6
0
Arquivo: type.go Projeto: dashaus/ark
func (v ArrayType) String() string {
	result := "(" + util.Blue("ArrayType") + ": "
	for _, attr := range v.attrs {
		result += attr.String() + " "
	}
	return result + v.TypeName() + ")" //+ util.Magenta(" <"+v.MangledName(MANGLE_ARK_UNSTABLE)+"> ") + ")"
}
Exemplo n.º 7
0
func (v *AccessExpr) String() string {
	result := "(" + util.Blue("AccessExpr") + ": "
	/*for _, struc := range v.StructVariables {
		result += struc.Name + "."
	}
	result += v.Variable.Name*/
	return result + ")"
}
Exemplo n.º 8
0
func (v *ReturnStat) String() string {
	ret := "(" + util.Blue("ReturnStat") + ": "
	if v.Value == nil {
		ret += "void"
	} else {
		ret += v.Value.String()
	}
	return ret + ")"
}
Exemplo n.º 9
0
func (v *MatchStat) String() string {
	result := "(" + util.Blue("MatchStat") + ": " + v.Target.String() + ":\n"

	for pattern, stmt := range v.Branches {
		result += "\t" + pattern.String() + " -> " + stmt.String() + "\n"
	}

	return result + ")"
}
Exemplo n.º 10
0
func (v *SizeofExpr) String() string {
	ret := "(" + util.Blue("SizeofExpr") + ": "
	if v.Expr != nil {
		ret += v.Expr.String()
	} else {
		ret += v.Type.TypeName()
	}
	return ret + ")"
}
Exemplo n.º 11
0
func (v *BoolLiteral) String() string {
	res := "(" + util.Blue("BoolLiteral") + ": "
	if v.Value {
		res += util.Yellow("true")
	} else {
		res += util.Yellow("false")
	}
	return res + ")"
}
Exemplo n.º 12
0
func (v *CallExpr) String() string {
	result := "(" + util.Blue("CallExpr") + ": " + v.Function.Name
	for _, arg := range v.Arguments {
		result += " " + arg.String()
	}
	if v.GetType() != nil {
		result += " " + util.Green(v.GetType().TypeName())
	}
	return result + ")"
}
Exemplo n.º 13
0
func (v *Variable) String() string {
	result := "(" + util.Blue("Variable") + ": "
	if v.Mutable {
		result += util.Green("[mutable] ")
	}
	for _, attr := range v.Attrs {
		result += attr.String() + " "
	}
	return result + v.Name + util.Magenta(" <"+v.MangledName(MANGLE_ARK_UNSTABLE)+"> ") + util.Green(v.Type.TypeName()) + ")"
}
Exemplo n.º 14
0
func (v *AssignStat) String() string {
	result := "(" + util.Blue("AssignStat") + ": "
	if v.Deref != nil {
		result += v.Deref.String()

	} else if v.Access != nil {
		result += v.Access.String()
	}
	return result + " = " + v.Assignment.String() + ")"
}
Exemplo n.º 15
0
Arquivo: type.go Projeto: dashaus/ark
func (v *TraitType) String() string {
	result := "(" + util.Blue("TraitType") + ": "
	for _, attr := range v.attrs {
		result += attr.String() + " "
	}
	result += v.Name + "\n"
	for _, decl := range v.Functions {
		result += "\t" + decl.String() + "\n"
	}
	return result + util.Magenta(" <"+v.MangledName(MANGLE_ARK_UNSTABLE)+"> ") + ")"
}
Exemplo n.º 16
0
func (v *IfStat) String() string {
	result := "(" + util.Blue("IfStat") + ": "
	for i, expr := range v.Exprs {
		result += expr.String() + " "
		result += v.Bodies[i].String()
	}
	if v.Else != nil {
		result += v.Else.String()
	}
	return result + ")"
}
Exemplo n.º 17
0
func (v *ModuleDecl) String() string {
	result := "(" + util.Blue(v.Module.Name) + " (in " + util.Green(v.Module.Path) + "): \n"
	// todo interfaces for this shit
	for _, function := range v.Module.Functions {
		result += "\t" + function.String() + "\n"
	}
	for _, variable := range v.Module.Variables {
		result += "\t" + variable.String() + "\n"
	}
	result += ")"
	return result
}
Exemplo n.º 18
0
func (v *LoopStat) String() string {
	result := "(" + util.Blue("LoopStat") + ": "

	switch v.LoopType {
	case LOOP_TYPE_INFINITE:
	case LOOP_TYPE_CONDITIONAL:
		result += v.Condition.String() + " "
	default:
		panic("invalid loop type")
	}

	result += v.Body.String()

	return result + ")"
}
Exemplo n.º 19
0
func (v *Function) String() string {
	result := "(" + util.Blue("Function") + ": "
	if v.Mutable {
		result += util.Green("[mutable] ")
	}
	for _, attr := range v.Attrs {
		result += attr.String() + " "
	}
	result += v.Name
	for _, par := range v.Parameters {
		result += " " + par.String()
	}
	if v.ReturnType != nil {
		result += ": " + util.Green(v.ReturnType.TypeName()) + " "
	}

	if v.Body != nil {
		result += v.Body.String()
	}
	return result + util.Magenta(" <"+v.MangledName(MANGLE_ARK_UNSTABLE)+">") + ")"
}
Exemplo n.º 20
0
func (v *CastExpr) String() string {
	return "(" + util.Blue("CastExpr") + ": " + v.Expr.String() + " " + util.Green(v.GetType().TypeName()) + ")"
}
Exemplo n.º 21
0
func (v *UnaryExpr) String() string {
	return "(" + util.Blue("UnaryExpr") + ": " +
		v.Op.String() + " " + v.Expr.String() + ")"
}
Exemplo n.º 22
0
func (v *BinaryExpr) String() string {
	return "(" + util.Blue("BinaryExpr") + ": " + v.Lhand.String() + " " +
		v.Op.String() + " " +
		v.Rhand.String() + ")"
}
Exemplo n.º 23
0
func (v *StringLiteral) String() string {
	return "(" + util.Blue("StringLiteral") + ": " + colorizeEscapedString((EscapeString(v.Value))) + " " + util.Green(v.GetType().TypeName()) + ")"
}
Exemplo n.º 24
0
func (v *DerefExpr) String() string {
	return "(" + util.Blue("DerefExpr") + ": " + v.Expr.String() + ")"
}
Exemplo n.º 25
0
func (v *AddressOfExpr) String() string {
	return "(" + util.Blue("AddressOfExpr") + ": " + v.Access.String() + " " + util.Green(v.GetType().TypeName()) + ")"
}
Exemplo n.º 26
0
func (v *RuneLiteral) String() string {
	return fmt.Sprintf("(" + util.Blue("RuneLiteral") + ": " + colorizeEscapedString(EscapeString(string(v.Value))) + " " + util.Green(v.GetType().TypeName()) + ")")
}
Exemplo n.º 27
0
func (v *BracketExpr) String() string {
	return "(" + util.Blue("BracketExpr") + ": " + v.Expr.String() + ")"
}
Exemplo n.º 28
0
func (v *IntegerLiteral) String() string {
	return fmt.Sprintf("("+util.Blue("IntegerLiteral")+": "+util.Yellow("%d")+" "+util.Green(v.GetType().TypeName())+")", v.Value)
}
Exemplo n.º 29
0
func (v *DefaultMatchBranch) String() string {
	return "(" + util.Blue("DefaultMatchBranch") + ")"
}
Exemplo n.º 30
0
func (v *FloatingLiteral) String() string {
	return fmt.Sprintf("("+util.Blue("FloatingLiteral")+": "+util.Yellow("%f")+" "+util.Green(v.GetType().TypeName())+")", v.Value)
}