Esempio n. 1
0
        public override AstNode Visit(ConstructorInitializer node)
        {
            // Begin the node.
            builder.BeginNode(node);

            // Get the constructor and his type.
            Method constructor = (Method)node.GetConstructor();
            FunctionType functionType = constructor.GetFunctionType();

            // Push the implicit this.
            builder.CreateLoadArg(0);

            // Push the arguments.
            AstNode argExpr = node.GetArguments();
            int index = 1; // For the implicit this
            while(argExpr != null)
            {
                // Visit the argument.
                argExpr.Accept(this);

                // Coerce it.
                IChelaType argExprType = argExpr.GetNodeType();
                IChelaType argType = functionType.GetArgument(index++);
                if(argType != argExprType)
                    Cast(node, argExpr.GetNodeValue(), argExprType, argType);

                argExpr = argExpr.GetNext();
            }

            // Perform the constructor call.
            int numargs = index;
            builder.CreateCall(constructor, (uint)numargs);

            return builder.EndNode();
        }
Esempio n. 2
0
        public override AstNode Visit(ConstructorInitializer node)
        {
            // Visit the function arguments.
            VisitList(node.GetArguments());

            // Pick the function
            Function function = PickFunction(node, node.GetConstructorGroup(), ChelaType.GetFunctionGroupType(), null, (Expression)node.GetArguments());
            node.SetConstructor(function);

            return node;
        }