Пример #1
0
        public override bool Equals(BType p)
        {
            if ((object)p == null)
            {
                return(false);
            }

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

            return(GetType() == p.GetType());
        }
Пример #3
0
        public override bool Equals(BType p)
        {
            if ((object)p == null)
            {
                return(false);
            }

            return(this.GetType() == p.GetType() && (p as BTypeArray).ArraySize == ArraySize);
        }
Пример #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);
        }
Пример #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);
            }
        }
Пример #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);
                }
            }
        }
Пример #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;
            }
        }
Пример #8
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeStack && (other as BTypeStack).StackSize == StackSize && (other is BTypeBoolStack));
 }
Пример #9
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeArray && (other as BTypeArray).ArraySize == ArraySize && (other is BTypeBoolArr));
 }
Пример #10
0
 public abstract bool IsImplicitCastableTo(BType other);
Пример #11
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeBool);
 }
Пример #12
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(other is BTypeDigit || other is BTypeInt);
 }
Пример #13
0
 public override bool IsImplicitCastableTo(BType other)
 {
     return(true);
 }