예제 #1
0
        public override Expression InstantiateTemplate(Dictionary <string, TypeName> parameters)
        {
            CallExpression result = new CallExpression(this, parent.InstantiateTemplate(parameters));

            foreach (Expression param in this.parameters)
            {
                result.AddParameter(param.InstantiateTemplate(parameters));
            }
            return(result);
        }
예제 #2
0
        public void AddCollectionInitializer(List <Expression> expression)
        {
            Require.False(Resolved);
            collectionInitializer.Add(expression);
            CallExpression call = new CallExpression(this, new FieldExpression(this, new PrepareIsolationExpression(stackTopExpression), new Identifier(this, "Add")));

            foreach (Expression e in expression)
            {
                call.AddParameter(e);
            }
            collectionAddition.Add(call);
        }
예제 #3
0
        public override void Prepare(Generator generator, TypeReference inferredType)
        {
            base.Prepare(generator, inferredType);
            parent.Prepare(generator, null);

            TypeReference parentType = parent.TypeReference;
//            if (parentType.IsNullable)
//                parentType = ((NullableTypeReference)parentType).Parent;

            FieldExpression field = new FieldExpression(this, new Identifier(this, name));

            field.SetParentDoNotGenerate(parent);
            call = new CallExpression(this, field);
            call.AddParameter(argument);
            call.ParametersPreResolved();
            call.Resolve(generator);
            call.Prepare(generator, null);
            type = call.TypeReference;

            string signature = parentType.TypeName.Data + ":" + name + ":" + argument.TypeReference.TypeName.Data;

            // unassign call if it is build in
            if ((signature == "pluk.base.Int:OperatorEquals:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorNotEquals:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorGreaterThan:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorLessThan:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorGreaterEquals:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorLessEquals:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorAdd:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorSubtract:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorLeft:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorRight:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorMultiply:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorModulo:pluk.base.Int") ||
                (signature == "pluk.base.Int:OperatorDivide:pluk.base.Int")

                || (signature == "pluk.base.Bool:OperatorEquals:pluk.base.Bool") ||
                (signature == "pluk.base.Bool:OperatorNotEquals:pluk.base.Bool")

                || (signature == "pluk.base.Byte:OperatorEquals:pluk.base.Byte") ||
                (signature == "pluk.base.Byte:OperatorNotEquals:pluk.base.Byte") ||
                (signature == "pluk.base.Byte:OperatorGreaterThan:pluk.base.Byte") ||
                (signature == "pluk.base.Byte:OperatorLessThan:pluk.base.Byte") ||
                (signature == "pluk.base.Byte:OperatorGreaterEquals:pluk.base.Byte") ||
                (signature == "pluk.base.Byte:OperatorLessEquals:pluk.base.Byte")
                )
            {
                call = null;
            }
        }
예제 #4
0
        public override void Prepare(Generator generator, TypeReference inferredType)
        {
            base.Prepare(generator, inferredType);
            left.Prepare(generator, null);
            TypeReference leftType = left.TypeReference;

            if (leftType.TypeName.Data == "pluk.base.Bool")
            {
                right.Prepare(generator, leftType);
                type = leftType;
            }
            else
            {
                FieldExpression field = new FieldExpression(this, new Identifier(this, "OperatorOr"));
                field.SetParentDoNotGenerate(left);
                call = new CallExpression(this, field);
                call.AddParameter(right);
                call.Resolve(generator);
                call.Prepare(generator, inferredType);
                type = call.TypeReference;
            }
        }
예제 #5
0
 public void AddParameter(Expression expression)
 {
     parameters.Add(expression);
     call.AddParameter(expression);
 }