Esempio n. 1
0
File: ast.go Progetto: vnev/ark
func (v *NumericLiteral) String() string {
	if v.IsFloat {
		return fmt.Sprintf("("+util.Blue("NumericLiteral")+": "+util.Yellow("%d")+" "+util.Green(v.GetType().TypeName())+")", v.FloatValue)
	} else {
		return fmt.Sprintf("("+util.Blue("NumericLiteral")+": "+util.Yellow("%d")+" "+util.Green(v.GetType().TypeName())+")", v.IntValue)
	}
}
Esempio n. 2
0
File: ast.go Progetto: vnev/ark
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() + ")"
	}
}
Esempio n. 3
0
File: ast.go Progetto: vnev/ark
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 + ")"
}
Esempio 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 + ")"
}
Esempio n. 5
0
func (v *TupleType) String() string {
	result := "(" + util.Blue("TupleType") + ": "
	for _, mem := range v.Members {
		result += "\t" + mem.TypeName() + "\n"
	}
	return result + ")"
}
Esempio n. 6
0
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)+"> ") + ")"
}
Esempio n. 7
0
func (v *InterfaceType) String() string {
	result := "(" + util.Blue("InterfaceType") + ": "
	/*for _, mem := range v.Members {
		result += "\t" + mem.TypeName() + "\n"
	}*/
	return result + ")"
}
Esempio n. 8
0
func (v *ArrayLiteral) String() string {
	res := "(" + util.Blue("ArrayLiteral") + ":"
	for _, mem := range v.Members {
		res += " " + mem.String()
	}
	return res + ")"
}
Esempio n. 9
0
func (v *ImplDecl) String() string {
	var result string
	for _, decl := range v.Functions {
		result += "\t" + decl.String() + "\n"
	}
	return "(" + util.Blue("ImplDecl") + ": " + result + ")"
}
Esempio n. 10
0
File: ast.go Progetto: vnev/ark
func (v *TupleLiteral) String() string {
	res := "(" + util.Blue("TupleLiteral") + ": "
	for _, mem := range v.Members {
		res += mem.String()
		res += ", "
	}
	return res + ")"
}
Esempio n. 11
0
func (v InterfaceType) String() string {
	result := "(" + util.Blue("InterfaceType") + ": "
	for _, function := range v.Functions {
		result += "\t" + function.String() + "\n"
	}
	result += "}"
	return result + ")"
}
Esempio n. 12
0
File: ast.go Progetto: vnev/ark
func (v *BoolLiteral) String() string {
	res := "(" + util.Blue("BoolLiteral") + ": "
	if v.Value {
		res += util.Yellow("true")
	} else {
		res += util.Yellow("false")
	}
	return res + ")"
}
Esempio n. 13
0
File: ast.go Progetto: vnev/ark
func (v *ReturnStat) String() string {
	ret := "(" + util.Blue("ReturnStat") + ": "
	if v.Value == nil {
		ret += "void"
	} else {
		ret += v.Value.String()
	}
	return ret + ")"
}
Esempio n. 14
0
File: ast.go Progetto: vnev/ark
func (v *SizeofExpr) String() string {
	ret := "(" + util.Blue("SizeofExpr") + ": "
	if v.Expr != nil {
		ret += v.Expr.String()
	} else {
		ret += v.Type.TypeName()
	}
	return ret + ")"
}
Esempio n. 15
0
File: ast.go Progetto: vnev/ark
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 + ")"
}
Esempio n. 16
0
File: ast.go Progetto: vnev/ark
func (v *EnumLiteral) String() string {
	res := "(" + util.Blue("EnumLiteral") + ":"
	if v.TupleLiteral != nil {
		res += v.TupleLiteral.String()
	} else if v.CompositeLiteral != nil {
		res += v.CompositeLiteral.String()
	}
	return res + ")"
}
Esempio n. 17
0
func (v StructType) String() string {
	result := "(" + util.Blue("StructType") + ": "
	result += v.attrs.String()
	result += "\n"
	for _, mem := range v.Members {
		result += "\t" + mem.Name + ": " + mem.Type.String() + "\n"
	}
	return result + ")"
}
Esempio n. 18
0
func (v *StructLiteral) String() string {
	res := "(" + util.Blue("StructLiteral") + ": "
	for name, value := range v.Values {
		res += name
		res += ": "
		res += value.String()
		res += ", "
	}
	return res + ")"
}
Esempio n. 19
0
File: ast.go Progetto: vnev/ark
func (v *CallExpr) String() string {
	result := "(" + util.Blue("CallExpr") + ": " + v.Function.String()
	for _, arg := range v.Arguments {
		result += " " + arg.String()
	}
	if v.GetType() != nil {
		result += " " + util.Green(v.GetType().TypeName())
	}
	return result + ")"
}
Esempio n. 20
0
File: ast.go Progetto: vnev/ark
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()) + ")"
}
Esempio n. 21
0
File: ast.go Progetto: vnev/ark
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 + ")"
}
Esempio n. 22
0
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)+"> ") + ")"
}
Esempio n. 23
0
func (v *StructType) String() string {
	result := "(" + util.Blue("StructType") + ": "
	for _, attr := range v.attrs {
		result += attr.String() + " "
	}
	result += "\n"
	for _, decl := range v.Variables {
		result += "\t" + decl.String() + "\n"
	}
	return result + ")"
}
Esempio n. 24
0
File: ast.go Progetto: vnev/ark
func (v *CompositeLiteral) String() string {
	res := "(" + util.Blue("CompositeLiteral") + ": "
	for i, mem := range v.Values {
		if field := v.Fields[i]; field != "" {
			res += field + ": "
		}

		res += mem.String() + ", "
	}
	return res + ")"
}
Esempio n. 25
0
func (v *EnumType) String() string {
	result := "(" + util.Blue("EnumType") + ": "
	for _, attr := range v.attrs {
		result += attr.String() + " "
	}

	result += "\n"

	for _, mem := range v.Members {
		result += "\t" + mem.Name + ": " + mem.Type.TypeName() + "\n"
	}
	return result + ")"
}
Esempio n. 26
0
File: type.go Progetto: vnev/ark
func (v *NamedType) String() string {
	res := "(" + util.Blue("NamedType") + ": " + v.Name
	if len(v.Parameters) > 0 {
		res += "<"
		for idx, param := range v.Parameters {
			res += param.TypeName()
			if idx < len(v.Parameters)-1 {
				res += ", "
			}
		}
		res += ">"
	}
	return res + " = " + v.Type.TypeName() + ")"
}
Esempio n. 27
0
File: ast.go Progetto: vnev/ark
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 + ")"
}
Esempio n. 28
0
File: ast.go Progetto: vnev/ark
func (v *Function) String() string {
	result := "(" + util.Blue("Function") + ": "
	for _, attr := range v.Type.Attrs() {
		result += attr.String() + " "
	}
	result += v.Name
	for _, par := range v.Parameters {
		result += " " + par.String()
	}
	if v.Type.Return != nil {
		result += ": " + util.Green(v.Type.Return.TypeName()) + " "
	}

	if v.Body != nil {
		result += v.Body.String()
	}
	return result + util.Magenta(" <"+v.MangledName(MANGLE_ARK_UNSTABLE)+">") + ")"
}
Esempio n. 29
0
func (v *UnresolvedType) String() string {
	return "(" + util.Blue("UnresolvedType") + ": " + v.Name.String() + ")"
}
Esempio n. 30
0
func (v *NamedType) String() string {
	return "(" + util.Blue("NamedType") + ": " + v.Type.TypeName() + ")"
}