Ejemplo n.º 1
0
func (v *Constructor) constructType(node parser.ParseNode) Type {
	switch node := node.(type) {
	case *parser.ReferenceTypeNode:
		return v.constructReferenceTypeNode(node)
	case *parser.PointerTypeNode:
		return v.constructPointerTypeNode(node)
	case *parser.TupleTypeNode:
		return v.constructTupleTypeNode(node)
	case *parser.FunctionTypeNode:
		return v.constructFunctionTypeNode(node)
	case *parser.ArrayTypeNode:
		return v.constructArrayTypeNode(node)
	case *parser.NamedTypeNode:
		return v.constructNamedTypeNode(node)
	case *parser.InterfaceTypeNode:
		return v.constructInterfaceTypeNode(node)
	case *parser.StructTypeNode:
		return v.constructStructTypeNode(node)
	case *parser.EnumTypeNode:
		return v.constructEnumTypeNode(node)

	default:
		log.Infoln("constructor", "Type of node: %s", reflect.TypeOf(node))
		panic("Encountered un-constructable node")
	}
}
Ejemplo n.º 2
0
func (v *Constructor) constructExpr(node ParseNode) Expr {
	switch node.(type) {
	case ConstructableExpr:
		return node.(ConstructableExpr).construct(v)

	default:
		log.Infoln("constructor", "Type of node: %s", reflect.TypeOf(node))
		panic("Encountered un-constructable node")
	}
}
Ejemplo n.º 3
0
func (v *Constructor) constructExpr(node parser.ParseNode) Expr {
	switch node := node.(type) {
	case *parser.BinaryExprNode:
		return v.constructBinaryExprNode(node)
	case *parser.ArrayLenExprNode:
		return v.constructArrayLenExprNode(node)
	case *parser.SizeofExprNode:
		return v.constructSizeofExprNode(node)
	case *parser.AddrofExprNode:
		return v.constructAddrofExprNode(node)
	case *parser.CastExprNode:
		return v.constructCastExprNode(node)
	case *parser.UnaryExprNode:
		return v.constructUnaryExprNode(node)
	case *parser.CallExprNode:
		return v.constructCallExprNode(node)
	case *parser.VariableAccessNode:
		return v.constructVariableAccessNode(node)
	case *parser.StructAccessNode:
		return v.constructStructAccessNode(node)
	case *parser.ArrayAccessNode:
		return v.constructArrayAccessNode(node)
	case *parser.DiscardAccessNode:
		return v.constructDiscardAccessNode(node)
	case *parser.EnumPatternNode:
		return v.constructEnumPatternNode(node)
	case *parser.TupleLiteralNode:
		return v.constructTupleLiteralNode(node)
	case *parser.CompositeLiteralNode:
		return v.constructCompositeLiteralNode(node)
	case *parser.BoolLitNode:
		return v.constructBoolLitNode(node)
	case *parser.NumberLitNode:
		return v.constructNumberLitNode(node)
	case *parser.StringLitNode:
		return v.constructStringLitNode(node)
	case *parser.RuneLitNode:
		return v.constructRuneLitNode(node)
	case *parser.LambdaExprNode:
		return v.constructLambdaExprNode(node)

	default:
		log.Infoln("constructor", "Type of node: %s", reflect.TypeOf(node))
		panic("Encountered un-constructable node")
	}
}
Ejemplo n.º 4
0
func (v *Constructor) constructNode(node parser.ParseNode) Node {
	switch node := node.(type) {
	case *parser.TypeDeclNode:
		return v.constructTypeDeclNode(node)
	case *parser.LinkDirectiveNode:
		return v.constructLinkDirectiveNode(node)
	case *parser.UseDirectiveNode:
		return v.constructUseDirectiveNode(node)
	case *parser.FunctionDeclNode:
		return v.constructFunctionDeclNode(node)
	case *parser.VarDeclNode:
		return v.constructVarDeclNode(node)
	case *parser.DestructVarDeclNode:
		return v.constructDestructVarDeclNode(node)
	case *parser.DeferStatNode:
		return v.constructDeferStatNode(node)
	case *parser.IfStatNode:
		return v.constructIfStatNode(node)
	case *parser.MatchStatNode:
		return v.constructMatchStatNode(node)
	case *parser.LoopStatNode:
		return v.constructLoopStatNode(node)
	case *parser.ReturnStatNode:
		return v.constructReturnStatNode(node)
	case *parser.BreakStatNode:
		return v.constructBreakStatNode(node)
	case *parser.NextStatNode:
		return v.constructNextStatNode(node)
	case *parser.BlockStatNode:
		return v.constructBlockStatNode(node)
	case *parser.BlockNode:
		return v.constructBlockNode(node)
	case *parser.CallStatNode:
		return v.constructCallStatNode(node)
	case *parser.AssignStatNode:
		return v.constructAssignStatNode(node)
	case *parser.BinopAssignStatNode:
		return v.constructBinopAssignStatNode(node)

	default:
		log.Infoln("constructor", "Type of node: %s", reflect.TypeOf(node))
		panic("Encountered un-constructable node")
	}
}