Example #1
0
        public override bool Equals(BType p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(this.GetType() == p.GetType() && (p as BTypeStack).StackSize == StackSize);
        }
Example #2
0
        public virtual bool Equals(BType p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(GetType() == p.GetType());
        }
Example #3
0
        public override bool Equals(BType p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(this.GetType() == p.GetType() && (p as BTypeArray).ArraySize == ArraySize);
        }
Example #4
0
        public Method(SourceCodePosition pos, BType t, string id, List <VarDeclaration> p, List <VarDeclaration> v, StatementStatementList b)
            : base(pos)
        {
            this.ResultType = t;
            this.Identifier = id;
            this.Parameter  = p;

            this.Variables = v;
            this.Body      = b;

            Variables.AddRange(Parameter);
        }
Example #5
0
        public MethodHeader(SourceCodePosition pos, BType t, string ident, List <VarDeclaration> p)
            : base(pos)
        {
            this.ResultType = t;
            this.Identifier = ident;
            this.Parameter  = p;

            if (ASTObject.IsKeyword(ident))
            {
                throw new IllegalIdentifierException(Position, ident);
            }
        }
Example #6
0
        private static VarDeclaration CreateAstDeclarationFromValues(BType type, string ident, Literal initArr, SourceCodePosition p)
        {
            if (initArr != null)
            {
                if (type is BTypeArray)
                {
                    return(new VarDeclarationArray(p, (BTypeArray)type, ident, (LiteralArray)initArr));
                }
                else if (type is BTypeValue)
                {
                    return(new VarDeclarationValue(p, (BTypeValue)type, ident, (LiteralValue)initArr));
                }
                else if (type is BTypeStack)
                {
                    if (initArr != null)
                    {
                        throw new CannotInitStackException(p);
                    }

                    return(new VarDeclarationStack(p, (BTypeStack)type, ident));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (type is BTypeArray)
                {
                    return(new VarDeclarationArray(p, (BTypeArray)type, ident));
                }
                else if (type is BTypeValue)
                {
                    return(new VarDeclarationValue(p, (BTypeValue)type, ident));
                }
                else if (type is BTypeStack)
                {
                    return(new VarDeclarationStack(p, (BTypeStack)type, ident));
                }
                else
                {
                    return(null);
                }
            }
        }
Example #7
0
        public VarDeclaration(SourceCodePosition pos, BType t, string ident, Literal init)
            : base(pos)
        {
            this.Type       = t;
            this.Identifier = ident;
            this.ID         = V_ID_COUNTER;
            this.IsConstant = false;

            if (ASTObject.IsKeyword(ident))
            {
                throw new IllegalIdentifierException(Position, ident);
            }

            if (init == null)
            {
                this.Initial = t.GetDefaultValue();
                HasCompleteUserDefiniedInitialValue = false;
            }
            else
            {
                this.Initial = init;
                HasCompleteUserDefiniedInitialValue = true;
            }
        }
Example #8
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeStack && (other as BTypeStack).StackSize == StackSize && (other is BTypeBoolStack));
 }
Example #9
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeArray && (other as BTypeArray).ArraySize == ArraySize && (other is BTypeBoolArr));
 }
Example #10
0
 public abstract bool IsImplicitCastableTo(BType other);
Example #11
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeBool);
 }
Example #12
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeDigit || other is BTypeInt);
 }
Example #13
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(true);
 }