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

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

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

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