public CaseToken(SimpleToken tokenInfo) : base(tokenInfo) { }
public static GlobalSymbolInfo Lookup(SimpleToken token) { return (GlobalSymbolInfo)globalSymbolTable.Table[token.Text.ToUpper()]; }
// Maps method-local IDs to local variable information public SymbolInfo Lookup(SimpleToken token) { return (SymbolInfo)Table[token.Text.ToUpper()]; }
public DatOrgxEntry(SimpleToken orgxToken) { this.orgxToken = orgxToken; }
public ObjSymbolInfo(IdToken idToken, SimpleToken filenameToken, Expr countExpr, bool needsVarSpace) : base(idToken) { this.filenameToken = filenameToken; this.countExpr = countExpr; this.needsVarSpace = needsVarSpace; }
public DatFileEntry(SimpleToken fileToken, SimpleToken filenameToken, byte[] bytes, int endLineNumber) { this.fileToken = fileToken; this.filenameToken = filenameToken; this.bytes = bytes; this.endLineNumber = endLineNumber; }
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; }
public void AddDatOrgEntry(SimpleToken orgToken, Expr orgExpr, int endLineNumber) { datEntryList.Add(new DatOrgEntry(orgToken, orgExpr, endLineNumber)); }
public void AddDatOrgxEntry(SimpleToken orgxToken) { datEntryList.Add(new DatOrgxEntry(orgxToken)); }
public void AddDatFitEntry(SimpleToken token, Expr e) { datEntryList.Add(new DatFitEntry(token, e)); }
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)); }
public void AddDatFileEntry(SimpleToken fileToken, SimpleToken filenameToken, byte[] bytes, int endLineNumber) { datEntryList.Add(new DatFileEntry(fileToken, filenameToken, bytes, endLineNumber)); }
public void AddDatDataEntry(int alignment, int size, Expr dataExpr, Expr countExpr, SimpleToken token) { datEntryList.Add(new DatDataEntry(alignment, size, dataExpr, countExpr, token)); }
public ClksetToken(SimpleToken tokenInfo) : base(tokenInfo) { }
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; }
public void AddDatResEntry(SimpleToken resToken, Expr e, int endLineNumber) { datEntryList.Add(new DatResEntry(resToken, e, endLineNumber)); }
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; }
public void AddDatSourceReference(SimpleToken endToken) { // Using SourceReference to mark the end of a line of data entries. datEntryList.Add(new SourceReference(endToken, endToken.LineNumber)); }
public DatFitEntry(SimpleToken token, Expr e) { this.token = token; this.e = e; }
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); }
public DatOrgEntry(SimpleToken orgToken, Expr orgExpr, int endLineNumber) { this.orgToken = orgToken; this.orgExpr = orgExpr; this.endLineNumber = endLineNumber; }
public GlobalSymbolInfo AddToGlobalSymbolTable(SimpleToken token) { return GlobalSymbolTable.Add(token, this); }
public DatResEntry(SimpleToken resToken, Expr e, int endLineNumber) { this.resToken = resToken; this.e = e; this.endLineNumber = endLineNumber; }
public GlobalSymbolInfo(SimpleToken idToken, ObjectFileSymbolTable symbolTable) : base(idToken) { this.symbolTable = symbolTable; }
public SymbolInfo(SimpleToken idToken) { this.idToken = idToken; }
// 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); }
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; }
// 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; }
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; }
public BlockDesignatorToken(SimpleToken tokenInfo) : base(tokenInfo) { }