5 public class StandardCodeWriter implements CodeWriter {
7 boolean linestarted = false;
9 Stack symboltables = new Stack();
10 InvariantValue ivalue;
12 public StandardCodeWriter(PrintWrapper output) { this.output = output; }
13 public StandardCodeWriter(java.io.PrintWriter output) { this.output = new PrintWrapper(output);}
15 public void startBuffer() {
18 public void emptyBuffer() {
22 public void startblock() {
27 public void endblock() {
31 public void addDeclaration(String type, String varname) {
32 output.addDeclaration(type,varname);
34 public void addDeclaration(String f) {
35 output.addDeclaration(f);
38 public void indent() {
42 public void unindent() {
46 private void doindent() {
47 for (int i = 0; i < output.indent; i++) {
53 public void outputline(String s) {
62 public void output(String s) {
70 public void pushSymbolTable(SymbolTable st) {
71 symboltables.push(st);
74 public SymbolTable popSymbolTable() {
75 return (SymbolTable) symboltables.pop();
78 public SymbolTable getSymbolTable() {
79 if (symboltables.empty()) {
80 throw new IRException();
82 return (SymbolTable) symboltables.peek();
85 public InvariantValue getInvariantValue() {
89 public void setInvariantValue(InvariantValue iv) {