コード例 #1
0
 public IndexorExpression(ILocation location)
     : base(location)
 {
     field  = new FieldExpression(location, new Identifier(location, "OperatorGetIndex"));
     call   = new CallExpression(location, field);
     setter = false;
 }
コード例 #2
0
ファイル: SlotExpression.cs プロジェクト: bartwe/plukc
 public override void Prepare(Generator generator, TypeReference inferredType)
 {
     base.Prepare(generator, inferredType);
     Resolver.ImplicitField implicitSlot = generator.Resolver.FindImplicitField(name);
     if (implicitSlot != null)
     {
         Expression thisSlot = new DirectSlotExpression(this, implicitSlot.slot, implicitSlot.type);
         field = new FieldExpression(this, thisSlot, name);
         field.Resolve(generator);
         field.Prepare(generator, inferredType);
         type        = field.TypeReference;
         sideEffects = field.HasSideEffects();
     }
     else
     {
         if (generator.Resolver.ContainsSlot(name))
         {
             type = generator.Resolver.ResolveSlotType(name);
         }
         else if (!hasTypeName)
         {
             throw new CompilerException(this, string.Format(Resource.Culture, Resource.FailedToResolveVariable, name.Data));
         }
         else
         {
             if (typeName != null)
             {
                 type = typeName; //todo
             }
             useTypeName = true;
         }
     }
 }
コード例 #3
0
        public override void Prepare(Generator generator, TypeReference inferredType)
        {
            base.Prepare(generator, inferredType);
            parent.Prepare(generator, null);

            TypeReference parentType = parent.TypeReference;

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

            if (signature == "pluk.base.Bool:OperatorNot")
            {
                type = parentType;
            }
            else if (signature == "pluk.base.Int:OperatorNegate")
            {
                type = parentType;
            }
            else
            {
                FieldExpression field = new FieldExpression(this, new Identifier(this, name));
                field.SetParentDoNotGenerate(parent);
                call = new CallExpression(this, field);
                call.Resolve(generator);
                call.Prepare(generator, null);
                type = call.TypeReference;
            }
        }
コード例 #4
0
 private IndexorExpression(ILocation location, Expression parent)
     : base(location)
 {
     Require.Assigned(parent);
     this.parent = parent;
     field       = new FieldExpression(location, new Identifier(location, "OperatorSetIndex"));
     field.SetParent(parent);
     call   = new CallExpression(location, field);
     setter = true;
 }
コード例 #5
0
ファイル: SlotExpression.cs プロジェクト: bartwe/plukc
 protected override bool InnerNeedsInference(Generator generator, TypeReference inferredHint)
 {
     Resolver.ImplicitField implicitSlot = generator.Resolver.FindImplicitField(name);
     if (implicitSlot != null)
     {
         Expression      thisSlot = new DirectSlotExpression(this, implicitSlot.slot, implicitSlot.type);
         FieldExpression field    = new FieldExpression(this, thisSlot, name);
         field.Resolve(generator);
         return(field.NeedsInference(generator, inferredHint));
     }
     return(false);
 }
コード例 #6
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;
            }
        }
コード例 #7
0
ファイル: OrExpression.cs プロジェクト: bartwe/plukc
        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;
            }
        }