?? symbol.java
字號:
package jeex.tiny;
import java.util.*;
/**
* Attributes of an identifier are hold in a symbol.
*/
class Symbol {
/**
* Memory address of this identifier.
*/
int address;
/**
* Identifier name this symbol corespondent to.
*/
String name;
/**
* Only can be created in enter().
*/
private Symbol(String name,int address) {
this.name = name;
this.address = address;
}
public String toString() {
return name + ":" + address;
}
/**
* Create a symbol and put the symbol into symbol table.
* @param name - name of identifier
*/
static Symbol enter(String name) {
Symbol s = new Symbol(name,offset++);
symtab.put(name,s);
return s;
}
/**
* Returns a defined symbol. If not defined, return null.
* @param name - name of identifier
*/
static Symbol get(String name) {
return (Symbol)symtab.get(name);
}
/**
* Returns true if the name is entered in the symbol table.
*/
static boolean isDefined(String name) {
return symtab.containsKey(name);
}
/**
* Symbol table.
*/
static Map symtab = new HashMap();
/**
* Next created symbol's address, updated when a new symbol created in enter().
*/
static int offset = 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -