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:
Minero Aoki 2009-05-23 16:18:04 +00:00
parent 0f12ee78f1
commit c7254ff547
2 changed files with 24 additions and 16 deletions

View File

@ -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>
* net/loveruby/cflat/ir: rename class: BranchIf -> CJump.

View File

@ -81,12 +81,28 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
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) {
stmts.add(new LabelStmt(null, label));
}
private void jump(Location loc, Label target) {
stmts.add(new Jump(loc, 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) {
@ -278,7 +294,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
public Void visit(BreakNode node) {
try {
jump(currentBreakTarget());
jump(node.location(), currentBreakTarget());
}
catch (JumpError err) {
error(node, err.getMessage());
@ -288,7 +304,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
public Void visit(ContinueNode node) {
try {
jump(currentContinueTarget());
jump(node.location(), currentContinueTarget());
}
catch (JumpError err) {
error(node, err.getMessage());
@ -311,7 +327,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
}
public Void visit(GotoNode node) {
stmts.add(new Jump(node.location(), referLabel(node.target())));
jump(node.location(), referLabel(node.target()));
return null;
}
@ -321,18 +337,6 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
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 {
public Label label;
public long numRefered;