示例#1
0
        public LocalObject AddLocalObject(string name, ObjectLevelID level, int offset)
        {
            LocalObject localObject = FindLocalObject(name);

            if (localObject != null && localObject.Level == level)
            {
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_LOCALSYMREDEF));
            }

            if (level == ObjectLevelID.FORMAL_PAREMETER)
            {
                formalParameters.Add(name, new LocalObject(name, level, offset));
                localObject = (LocalObject)formalParameters[name];
            }
            else if (level == ObjectLevelID.LOCAL_VARIABLE)
            {
                localVariables.Add(name, new LocalObject(name, level, offset));
                localObject = (LocalObject)localVariables[name];
            }
            else
            {
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADLOCALSYMLEVEL));
            }

            return(localObject);
        }
示例#2
0
        public int GetLocalObjectsOffset(string name)
        {
            LocalObject localObject = FindLocalObject(name);

            if (localObject != null)
            {
                return(localObject.Offset);
            }
            else
            {
                return(0);
            }
        }