Ejemplo n.º 1
0
        public ScopeObject DefineSymbol(ScopeAnalyser a, int name)
        {
            ScopeObject obj = new ScopeObject();

            obj.Name = name;
            obj.Kind = Kind.KindUndefined;
            obj.Next = a.SymbolTable[a.Level];
            a.SymbolTable[a.Level] = obj;
            return(obj);
        }
Ejemplo n.º 2
0
        public ScopeObject SearchLocalSymbol(ScopeAnalyser a, int name)
        {
            ScopeObject obj = a.SymbolTable[a.Level];

            while (obj != null)
            {
                if (obj.Name = name)
                {
                    return(obj);
                }
                obj = obj.Next;
            }
            return(obj);
        }
Ejemplo n.º 3
0
        public ScopeObject SearchGlobalSymbol(ScopeAnalyser a, int name)
        {
            ScopeObject obj = new ScopeObject();

            for (int i = a.Level; i >= 0; i--)
            {
                obj = a.SymbolTable[i];
                while (obj != null)
                {
                    if (obj.Name = name)
                    {
                        return(obj);
                    }
                    obj = obj.Next;
                }
            }

            return(obj);
        }
Ejemplo n.º 4
0
        public bool CheckTypes(ScopeAnalyser a, ScopeObject p1, ScopeObject p2)
        {
            ScopeObject UniversalObj = new ScopeObject();

            UniversalObj.Name = -1;
            UniversalObj.Kind = Kind.KindScalarType;
            if (p1.Equals(p2))
            {
                return(true);
            }
            else if (p1.Equals(UniversalObj) || p2.Equals(UniversalObj))
            {
                return(true);
            }
            else if (p1.Kind == Kind.KindUniversal || p2.Kind == Kind.KindUniversal)
            {
                return(true);
            }
            return(false);
        }