Beispiel #1
0
 public CaseToken(SimpleToken tokenInfo)
     : base(tokenInfo)
 {
 }
Beispiel #2
0
 public static GlobalSymbolInfo Lookup(SimpleToken token)
 {
     return (GlobalSymbolInfo)globalSymbolTable.Table[token.Text.ToUpper()];
 }
Beispiel #3
0
 // Maps method-local IDs to local variable information
 public SymbolInfo Lookup(SimpleToken token)
 {
     return (SymbolInfo)Table[token.Text.ToUpper()];
 }
Beispiel #4
0
 public DatOrgxEntry(SimpleToken orgxToken)
 {
     this.orgxToken = orgxToken;
 }
Beispiel #5
0
 public ObjSymbolInfo(IdToken idToken, SimpleToken filenameToken, Expr countExpr, bool needsVarSpace)
     : base(idToken)
 {
     this.filenameToken = filenameToken;
     this.countExpr = countExpr;
     this.needsVarSpace = needsVarSpace;
 }
Beispiel #6
0
 public DatFileEntry(SimpleToken fileToken, SimpleToken filenameToken, byte[] bytes, int endLineNumber)
 {
     this.fileToken = fileToken;
     this.filenameToken = filenameToken;
     this.bytes = bytes;
     this.endLineNumber = endLineNumber;
 }
Beispiel #7
0
 public DatInstructionEntry(IPropInstruction instruction, int cond, Expr eD, Expr eS, bool immediate, int effect, SimpleToken token, int endLineNumber)
 {
     this.instruction = instruction;
     this.cond = cond;
     this.eD = eD;
     this.eS = eS;
     this.immediate = immediate;
     this.effect = effect;
     this.token = token;
     this.endLineNumber = endLineNumber;
 }
Beispiel #8
0
 public void AddDatOrgEntry(SimpleToken orgToken, Expr orgExpr, int endLineNumber)
 {
     datEntryList.Add(new DatOrgEntry(orgToken, orgExpr, endLineNumber));
 }
Beispiel #9
0
 public void AddDatOrgxEntry(SimpleToken orgxToken)
 {
     datEntryList.Add(new DatOrgxEntry(orgxToken));
 }
Beispiel #10
0
 public void AddDatFitEntry(SimpleToken token, Expr e)
 {
     datEntryList.Add(new DatFitEntry(token, e));
 }
Beispiel #11
0
 public void AddDatInstructionEntry(IPropInstruction instruction, int cond, Expr eD, Expr eS, bool immediate, int effect, SimpleToken token, int endLineNumber)
 {
     datEntryList.Add(new DatInstructionEntry(instruction, cond, eD, eS, immediate, effect, token, endLineNumber));
 }
Beispiel #12
0
 public void AddDatFileEntry(SimpleToken fileToken, SimpleToken filenameToken, byte[] bytes, int endLineNumber)
 {
     datEntryList.Add(new DatFileEntry(fileToken, filenameToken, bytes, endLineNumber));
 }
Beispiel #13
0
 public void AddDatDataEntry(int alignment, int size, Expr dataExpr, Expr countExpr, SimpleToken token)
 {
     datEntryList.Add(new DatDataEntry(alignment, size, dataExpr, countExpr, token));
 }
Beispiel #14
0
 public ClksetToken(SimpleToken tokenInfo)
     : base(tokenInfo)
 {
 }
Beispiel #15
0
        public static GlobalSymbolInfo Add(SimpleToken token, ObjectFileSymbolTable objectFileSymbolTable)
        {
            // New global symbols are added to the global symbol table and to globalList (at the end).
            // Existing global symbols are moved to the end of globalList. This is done to duplicate
            // PropTool's behavior. Why PropTool does what it does I have no idea.
            // 7/24 Finally realized why: when the objects are laid out in this order, all
            // the inter-object offsets are positive.

            GlobalSymbolInfo gsi = GlobalSymbolTable.Lookup(token);
            if (gsi == null)
            {
                gsi = new GlobalSymbolInfo(token, objectFileSymbolTable);
                globalSymbolTable.AddSymbolInfo(gsi);
                globalList.Add(gsi);
            }
            else
            {
                if (!gsi.AlreadyRead)
                    throw new ParseException("Circular object reference", token);
                for (int i = 0; i < globalList.Count; ++i)
                {
                    if (globalList[i] == gsi)
                    {
                        globalList.RemoveAt(i);
                        globalList.Add(gsi);
                        break;
                    }
                }
            }
            return gsi;
        }
Beispiel #16
0
 public void AddDatResEntry(SimpleToken resToken, Expr e, int endLineNumber)
 {
     datEntryList.Add(new DatResEntry(resToken, e, endLineNumber));
 }
Beispiel #17
0
 public DatDataEntry(int alignment, int size, Expr dataExpr, Expr countExpr, SimpleToken token)
 {
     this.alignment = alignment;
     this.size = size;
     this.dataExpr = dataExpr;
     this.countExpr = countExpr;
     this.token = token;
 }
Beispiel #18
0
 public void AddDatSourceReference(SimpleToken endToken)
 {
     // Using SourceReference to mark the end of a line of data entries.
     datEntryList.Add(new SourceReference(endToken, endToken.LineNumber));
 }
Beispiel #19
0
 public DatFitEntry(SimpleToken token, Expr e)
 {
     this.token = token;
     this.e = e;
 }
Beispiel #20
0
 public void AddObjSymbol(IdToken idToken, SimpleToken filenameToken, Expr countExpr, bool needsVarSpace)
 {
     AssertUndefined(idToken);
     ObjSymbolInfo objSymbolInfo = new ObjSymbolInfo(idToken, filenameToken, countExpr, needsVarSpace);
     AddSymbolInfo(objSymbolInfo);
     objList.Add(objSymbolInfo);
 }
Beispiel #21
0
 public DatOrgEntry(SimpleToken orgToken, Expr orgExpr, int endLineNumber)
 {
     this.orgToken = orgToken;
     this.orgExpr = orgExpr;
     this.endLineNumber = endLineNumber;
 }
Beispiel #22
0
 public GlobalSymbolInfo AddToGlobalSymbolTable(SimpleToken token)
 {
     return GlobalSymbolTable.Add(token, this);
 }
Beispiel #23
0
 public DatResEntry(SimpleToken resToken, Expr e, int endLineNumber)
 {
     this.resToken = resToken;
     this.e = e;
     this.endLineNumber = endLineNumber;
 }
Beispiel #24
0
 public GlobalSymbolInfo(SimpleToken idToken, ObjectFileSymbolTable symbolTable)
     : base(idToken)
 {
     this.symbolTable = symbolTable;
 }
Beispiel #25
0
 public SymbolInfo(SimpleToken idToken)
 {
     this.idToken = idToken;
 }
Beispiel #26
0
        // Does a lookup in local symbol table (if we're in a method scope),
        // then object file symbol table, then global symbol table.
        // Returns null if id is not found.
        public SymbolInfo Lookup(SimpleToken idToken)
        {
            SymbolInfo symbolInfo = null;

            if (idToken.Text[0] == ':')
            {
                idToken.Text = latestLabel + idToken.Text;
            }

            if (localSymbolTable != null)
            {
                symbolInfo = localSymbolTable.Lookup(idToken);
                if (symbolInfo != null)
                    return symbolInfo;
            }

            symbolInfo = (SymbolInfo)Table[idToken.Text.ToUpper()];
            if (symbolInfo != null)
                return symbolInfo;

            return GlobalSymbolTable.Lookup(idToken);
        }
Beispiel #27
0
 public static GlobalSymbolInfo LookupExisting(SimpleToken token)
 {
     GlobalSymbolInfo gsi = (GlobalSymbolInfo)globalSymbolTable.Table[token.Text.ToUpper()];
     if (gsi == null)
         throw new ParseException("Couldn't find {0}", token);
     return gsi;
 }
Beispiel #28
0
 // Throws if id is not found.
 public SymbolInfo LookupExisting(SimpleToken idToken)
 {
     SymbolInfo symbolInfo = Lookup(idToken);
     if (symbolInfo == null)
         throw new ParseException("Unknown symbol " + idToken.Text, idToken);
     return symbolInfo;
 }
Beispiel #29
0
        public int Compile(int a)
        {
            this.Offset = a;	// Compiling bytecode to object starting at offset a.
            // This information is needed by Fixup for CASE/LOOKDOWN/LOOKUP and STRING offsets.
            int i = 0;
            int offset = 0;
            if (localNameList.Count > 0 && localNameList[0] == null)
            {
                i = 1;
                offset = 4;
            }
            localsSize = 0;

            IdToken.SymbolTable.BeginMethodScope();

            for (; i < localNameList.Count; ++i)
            {
                IdToken.SymbolTable.AddLocalVariable(localNameList[i] as IdToken, offset);
                ///Console.WriteLine( "assertundefined {0}", (localNameList[i] as IdToken).Text );;;
                ///IdToken.SymbolTable.AssertUndefined( localNameList[i] as IdToken );;;
                Expr countExpr = localCountList[i] as Expr;
                int d = 4;
                if (countExpr != null)
                    d = 4 * Expr.EvaluateIntConstant(countExpr);
                offset += d;
                if (i > paramCount) localsSize += d;
            }

            SimpleToken resultToken = new SimpleToken(IdToken.Tokenizer, SimpleTokenType.Id, "result", 0, 0);
            if (IdToken.SymbolTable.Lookup(resultToken) == null)
                IdToken.SymbolTable.AddLocalVariable(new IdToken(resultToken), 0);

            bytecodeList = new ArrayList();
            foreach (Stmt s in statementList)
            {
                s.MakeByteCode(bytecodeList);
            }
            bytecodeList.Add((byte)0x32);	// every method has an invisible RETURN;

            // Now append string literals.
            for (int j = 0; j < IdToken.SymbolTable.StringList.Count; ++j)
            {
                bytecodeList.Add((JmpTarget)IdToken.SymbolTable.StringTargetList[j]);
                bytecodeList.Add(new StringStart());
                string s = (string)IdToken.SymbolTable.StringList[j];
                foreach (char ch in s)
                {
                    bytecodeList.Add((byte)ch);
                }
                bytecodeList.Add((byte)0);
                bytecodeList.Add(new StringEnd());
            }

            while (BytecodeFixupPass(a))
            {
            }

            sizeInBytes = 0;
            foreach (object o in bytecodeList)
            {
                if (o is byte)
                {
                    ++sizeInBytes;
                }
                else if (o is JmpStart)
                {
                    sizeInBytes += (o as JmpStart).bytecode.Length;
                }
                else if (o is OffsetStart)
                {
                    sizeInBytes += (o as OffsetStart).bytecode.Length;
                }
                else if (o is StringOffsetStart)
                {
                    sizeInBytes += (o as StringOffsetStart).bytecode.Length;
                }
            }

            IdToken.SymbolTable.EndMethodScope();

            return a + sizeInBytes;
        }
Beispiel #30
0
 public BlockDesignatorToken(SimpleToken tokenInfo)
     : base(tokenInfo)
 {
 }