Esempio n. 1
0
        internal override Expression Resolve(ParserContext parser)
        {
            this.Condition  = this.Condition.Resolve(parser);
            this.TrueValue  = this.TrueValue.Resolve(parser);
            this.FalseValue = this.FalseValue.Resolve(parser);

            BooleanConstant bc = this.Condition as BooleanConstant;

            if (bc != null)
            {
                return(bc.Value ? this.TrueValue : this.FalseValue);
            }

            return(this);
        }
Esempio n. 2
0
        internal override IList <Executable> Resolve(ParserContext parser)
        {
            this.Condition = this.Condition.Resolve(parser);

            this.TrueCode  = Resolve(parser, this.TrueCode).ToArray();
            this.FalseCode = Resolve(parser, this.FalseCode).ToArray();

            BooleanConstant bc = this.Condition as BooleanConstant;

            if (bc != null)
            {
                return(bc.Value ? this.TrueCode : this.FalseCode);
            }

            return(Listify(this));
        }
Esempio n. 3
0
        private Assignment(bool nonAmbiguousIgnored, Expression target, AType nullableTypeDeclaration, Token assignmentOpToken, Ops op, Expression assignedValue, Node owner)
            : base(target.FirstToken, owner)
        {
            this.Target  = target;
            this.OpToken = assignmentOpToken;
            this.Op      = op;
            this.Value   = assignedValue;
            this.NullableTypeDeclaration = nullableTypeDeclaration;

            if (this.NullableTypeDeclaration != null)
            {
                this.type = AssignmentType.TYPED_VARIABLE_DECLARATION;

                if (this.Value == null)
                {
                    Expression defaultValue;
                    switch (this.NullableTypeDeclaration.RootType)
                    {
                    case "bool": defaultValue = new BooleanConstant(this.FirstToken, false, this.Owner); break;

                    case "int": defaultValue = new IntegerConstant(this.FirstToken, 0, this.Owner); break;

                    case "float": defaultValue = new FloatConstant(this.FirstToken, 0.0, this.Owner); break;

                    default: defaultValue = new NullConstant(this.FirstToken, this.Owner); break;
                    }
                    this.Value = defaultValue;
                }
            }
            else if (this.Target is Variable)
            {
                this.type = AssignmentType.VARIABLE;
            }
            else if (this.Target is BracketIndex)
            {
                this.type = AssignmentType.KEYED_ASSIGNMENT;
            }
            else if (this.Target is DotField || this.Target is FieldReference)
            {
                this.type = AssignmentType.FIELD_ASSIGNMENT;
            }
            else
            {
                throw new ParserException(this, "Cannot assign to this type of expression.");
            }
        }