mirror of https://github.com/aamine/cbc
r4892@macbookpro: aamine | 2009-05-24 00:41:44 +0900
* net/loveruby/cflat/ir: rename class: BranchIf -> CJump. * net/loveruby/cflat/ir/IRVisitor.java: follow it. * net/loveruby/cflat/compiler/IRGenerator.java: ditto. * net/loveruby/cflat/sysdep/x86/CodeGenerator.java: ditto. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4234 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
1e3eae4634
commit
0f12ee78f1
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sun May 24 00:42:28 2009 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/ir: rename class: BranchIf -> CJump.
|
||||
|
||||
* net/loveruby/cflat/ir/IRVisitor.java: follow it.
|
||||
|
||||
* net/loveruby/cflat/compiler/IRGenerator.java: ditto.
|
||||
|
||||
* net/loveruby/cflat/sysdep/x86/CodeGenerator.java: ditto.
|
||||
|
||||
Sun May 24 00:01:07 2009 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/IRGenerator.java: refactoring:
|
||||
|
|
|
@ -166,7 +166,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
Label elseLabel = new Label();
|
||||
Label endLabel = new Label();
|
||||
|
||||
branch(node.location(),
|
||||
cjump(node.location(),
|
||||
transformExpr(node.cond()),
|
||||
thenLabel,
|
||||
node.elseBody() == null ? endLabel : elseLabel);
|
||||
|
@ -222,7 +222,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
Label endLabel = new Label();
|
||||
|
||||
label(begLabel);
|
||||
branch(node.location(),
|
||||
cjump(node.location(),
|
||||
transformExpr(node.cond()), bodyLabel, endLabel);
|
||||
label(bodyLabel);
|
||||
pushContinue(begLabel);
|
||||
|
@ -248,7 +248,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
popBreak();
|
||||
popContinue();
|
||||
label(contLabel);
|
||||
branch(node.location(), transformExpr(node.cond()), begLabel, endLabel);
|
||||
cjump(node.location(), transformExpr(node.cond()), begLabel, endLabel);
|
||||
label(endLabel);
|
||||
return null;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
|
||||
transformStmt(node.init());
|
||||
label(begLabel);
|
||||
branch(node.location(),
|
||||
cjump(node.location(),
|
||||
transformExpr(node.cond()), bodyLabel, endLabel);
|
||||
label(bodyLabel);
|
||||
pushContinue(contLabel);
|
||||
|
@ -321,8 +321,8 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void branch(Location loc, Expr cond, Label thenLabel, Label elseLabel) {
|
||||
stmts.add(new BranchIf(loc, cond, thenLabel, elseLabel));
|
||||
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) {
|
||||
|
@ -399,7 +399,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
DefinedVariable var = tmpVar(node.type());
|
||||
|
||||
Expr cond = transformExpr(node.cond());
|
||||
branch(node.location(), cond, thenLabel, elseLabel);
|
||||
cjump(node.location(), cond, thenLabel, elseLabel);
|
||||
label(thenLabel);
|
||||
assign(node.thenExpr().location(),
|
||||
ref(var), transformExpr(node.thenExpr()));
|
||||
|
@ -419,7 +419,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
|
||||
assign(node.left().location(),
|
||||
ref(var), transformExpr(node.left()));
|
||||
branch(node.location(), ref(var), rightLabel, endLabel);
|
||||
cjump(node.location(), ref(var), rightLabel, endLabel);
|
||||
label(rightLabel);
|
||||
assign(node.right().location(),
|
||||
ref(var), transformExpr(node.right()));
|
||||
|
@ -434,7 +434,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
|
||||
assign(node.left().location(),
|
||||
ref(var), transformExpr(node.left()));
|
||||
branch(node.location(), ref(var), endLabel, rightLabel);
|
||||
cjump(node.location(), ref(var), endLabel, rightLabel);
|
||||
label(rightLabel);
|
||||
assign(node.right().location(),
|
||||
ref(var), transformExpr(node.right()));
|
||||
|
|
|
@ -2,13 +2,12 @@ package net.loveruby.cflat.ir;
|
|||
import net.loveruby.cflat.ast.Location;
|
||||
import net.loveruby.cflat.asm.Label;
|
||||
|
||||
public class BranchIf extends Stmt {
|
||||
public class CJump extends Stmt {
|
||||
protected Expr cond;
|
||||
protected Label thenLabel;
|
||||
protected Label elseLabel;
|
||||
|
||||
public BranchIf(Location loc, Expr cond,
|
||||
Label thenLabel, Label elseLabel) {
|
||||
public CJump(Location loc, Expr cond, Label thenLabel, Label elseLabel) {
|
||||
super(loc);
|
||||
this.cond = cond;
|
||||
this.thenLabel = thenLabel;
|
|
@ -3,10 +3,10 @@ package net.loveruby.cflat.ir;
|
|||
public interface IRVisitor<S,E> {
|
||||
public S visit(ExprStmt s);
|
||||
public S visit(Assign s);
|
||||
public S visit(BranchIf s);
|
||||
public S visit(CJump s);
|
||||
public S visit(Jump s);
|
||||
public S visit(Switch s);
|
||||
public S visit(LabelStmt s);
|
||||
public S visit(Jump s);
|
||||
public S visit(Return s);
|
||||
|
||||
public E visit(Uni s);
|
||||
|
|
|
@ -697,8 +697,8 @@ public class CodeGenerator
|
|||
}
|
||||
// #@@}
|
||||
|
||||
// #@@range/compile_BranchIf{
|
||||
public Void visit(BranchIf node) {
|
||||
// #@@range/compile_CJump{
|
||||
public Void visit(CJump node) {
|
||||
compile(node.cond());
|
||||
testCond(node.cond().type(), ax());
|
||||
as.jnz(node.thenLabel());
|
||||
|
|
Loading…
Reference in New Issue