mirror of https://github.com/aamine/cbc
r4893@macbookpro: aamine | 2009-05-24 01:17:52 +0900
* net/loveruby/cflat/compiler/IRGenerator.java: reorder methods. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4235 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
0f12ee78f1
commit
c7254ff547
|
@ -1,3 +1,7 @@
|
||||||
|
Sun May 24 01:18:36 2009 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* net/loveruby/cflat/compiler/IRGenerator.java: reorder methods.
|
||||||
|
|
||||||
Sun May 24 00:42:28 2009 Minero Aoki <aamine@loveruby.net>
|
Sun May 24 00:42:28 2009 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* net/loveruby/cflat/ir: rename class: BranchIf -> CJump.
|
* net/loveruby/cflat/ir: rename class: BranchIf -> CJump.
|
||||||
|
|
|
@ -81,12 +81,28 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
||||||
return (exprNestLevel == 0);
|
return (exprNestLevel == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assign(Location loc, Expr lhs, Expr rhs) {
|
||||||
|
stmts.add(new Assign(loc, addressOf(lhs), rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
private DefinedVariable tmpVar(Type t) {
|
||||||
|
return scopeStack.getLast().allocateTmp(t);
|
||||||
|
}
|
||||||
|
|
||||||
private void label(Label label) {
|
private void label(Label label) {
|
||||||
stmts.add(new LabelStmt(null, label));
|
stmts.add(new LabelStmt(null, label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void jump(Location loc, Label target) {
|
||||||
|
stmts.add(new Jump(loc, target));
|
||||||
|
}
|
||||||
|
|
||||||
private void jump(Label target) {
|
private void jump(Label target) {
|
||||||
stmts.add(new Jump(null, target));
|
jump(null, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cjump(Location loc, Expr cond, Label thenLabel, Label elseLabel) {
|
||||||
|
stmts.add(new CJump(loc, cond, thenLabel, elseLabel));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pushBreak(Label label) {
|
private void pushBreak(Label label) {
|
||||||
|
@ -278,7 +294,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
||||||
|
|
||||||
public Void visit(BreakNode node) {
|
public Void visit(BreakNode node) {
|
||||||
try {
|
try {
|
||||||
jump(currentBreakTarget());
|
jump(node.location(), currentBreakTarget());
|
||||||
}
|
}
|
||||||
catch (JumpError err) {
|
catch (JumpError err) {
|
||||||
error(node, err.getMessage());
|
error(node, err.getMessage());
|
||||||
|
@ -288,7 +304,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
||||||
|
|
||||||
public Void visit(ContinueNode node) {
|
public Void visit(ContinueNode node) {
|
||||||
try {
|
try {
|
||||||
jump(currentContinueTarget());
|
jump(node.location(), currentContinueTarget());
|
||||||
}
|
}
|
||||||
catch (JumpError err) {
|
catch (JumpError err) {
|
||||||
error(node, err.getMessage());
|
error(node, err.getMessage());
|
||||||
|
@ -311,7 +327,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Void visit(GotoNode node) {
|
public Void visit(GotoNode node) {
|
||||||
stmts.add(new Jump(node.location(), referLabel(node.target())));
|
jump(node.location(), referLabel(node.target()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,18 +337,6 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cjump(Location loc, Expr cond, Label thenLabel, Label elseLabel) {
|
|
||||||
stmts.add(new CJump(loc, cond, thenLabel, elseLabel));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assign(Location loc, Expr lhs, Expr rhs) {
|
|
||||||
stmts.add(new Assign(loc, addressOf(lhs), rhs));
|
|
||||||
}
|
|
||||||
|
|
||||||
private DefinedVariable tmpVar(Type t) {
|
|
||||||
return scopeStack.getLast().allocateTmp(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpEntry {
|
class JumpEntry {
|
||||||
public Label label;
|
public Label label;
|
||||||
public long numRefered;
|
public long numRefered;
|
||||||
|
|
Loading…
Reference in New Issue