Skip to content

Commit

Permalink
- Arrange logger level for some cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
whtoo committed Dec 5, 2023
1 parent 1fc0c2a commit dd4b663
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ep20/src/main/java/org/teachfx/antlr4/ep20/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public static void main(String[] args) throws IOException {
protected static void saveToEp18Res(String buffer) {
String modulePath = "../ep18/src/main/resources"; // 替换 "my-module" 为你的模块名称
File moduleDirectory = new File(modulePath);
logger.info("file path %s".formatted(moduleDirectory.getAbsolutePath()));
logger.trace("file path %s".formatted(moduleDirectory.getAbsolutePath()));
if (moduleDirectory.exists()) {
logger.info("模块路径:" + moduleDirectory.getAbsolutePath());
logger.trace("模块路径:" + moduleDirectory.getAbsolutePath());
var filePath = modulePath+"/t.vm";
File file = new File(filePath);
try (var outputStream = new FileOutputStream(file)) {
Expand Down
13 changes: 0 additions & 13 deletions ep20/src/main/java/org/teachfx/antlr4/ep20/pass/cfg/CFG.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ public String toString() {
return graphRenderBuffer.toString();
}

/// 1. receive two params : srcBlockId and destBlockId
/// 2. remove edge from edges and links
public void removeEdge(int srcBlockId, int destBlockId,int weight) {
edges.remove(Triple.of(srcBlockId, destBlockId,weight));
links.get(srcBlockId).getRight().remove(destBlockId);
links.get(destBlockId).getLeft().remove(srcBlockId);
}


/**
* remove edge from edges and links
Expand All @@ -141,11 +133,6 @@ public void removeEdge(Triple<Integer,Integer,Integer> edge) {
}
}

/// 1. receive one param : id
public void removeNodeById(int id) {
/// 2. remove node from nodes by its id
nodes.removeIf(bb -> bb.getId() == id);
}
public void removeNode(BasicBlock<I> node) {
/// 2. remove node from nodes by its id
nodes.removeIf(bb -> bb.equals(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public LinearIRBlock(Scope scope) {
predecessors = new ArrayList<>();
ord = LABEL_SEQ++;
this.scope = scope;
logger.info(ord);
logger.trace(ord);
}

public LinearIRBlock() {
Expand All @@ -41,7 +41,7 @@ public LinearIRBlock() {
predecessors = new ArrayList<>();
ord = LABEL_SEQ++;
this.scope = null;
logger.info(ord);
logger.trace(ord);
}
public static boolean isBasicBlock(Stmt stmt) {
return !(stmt instanceof CJMP) && !(stmt instanceof JMP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public class CymbolIRBuilder implements ASTVisitor<Void, VarSlot> {
@Override
public Void visit(CompileUnit compileUnit) {
prog = new Prog();
logger.info("visit root");
logger.debug("visit root");
compileUnit.getFuncDeclarations().forEach(x -> x.accept(this));

return null;
}

@Override
public Void visit(VarDeclNode varDeclNode) {
logger.info("visit %s".formatted(varDeclNode.toString()));
logger.debug("visit %s".formatted(varDeclNode.toString()));

if(varDeclNode.hasInitializer()){
var lhsNode = (IDExprNode)varDeclNode.getIdExprNode();
Expand All @@ -70,7 +70,7 @@ public Void visit(VarDeclNode varDeclNode) {

@Override
public Void visit(FuncDeclNode funcDeclNode) {
logger.info("visit %s".formatted(funcDeclNode.toString()));
logger.debug("visit %s".formatted(funcDeclNode.toString()));

curNode = funcDeclNode;
var methodSymbol = (MethodSymbol) funcDeclNode.getRefSymbol();
Expand Down Expand Up @@ -103,7 +103,7 @@ public Void visit(FuncDeclNode funcDeclNode) {

@Override
public Void visit(VarDeclStmtNode varDeclStmtNode) {
logger.info("visit %s".formatted(varDeclStmtNode.toString()));
logger.debug("visit %s".formatted(varDeclStmtNode.toString()));
if (varDeclStmtNode.getVarDeclNode().hasInitializer()) {
varDeclStmtNode.getVarDeclNode().accept(this);
}
Expand Down Expand Up @@ -392,19 +392,19 @@ public void popContinueStack() {
protected VarSlot pushEvalOperand(Operand operand) {

if (curNode != null) {
logger.info(curNode.toString());
logger.debug(curNode.toString());
}

if (!(operand instanceof OperandSlot)){
cnt++;
var assignee = OperandSlot.pushStack();
evalExprStack.push(assignee);
addInstr(Assign.with(assignee, operand));
logger.info("-> eval stack %s%n", evalExprStack.toString());
logger.debug("-> eval stack %s%n", evalExprStack.toString());

return assignee;
} else {
logger.info("-> eval stack %s%n", evalExprStack.toString());
logger.debug("-> eval stack %s%n", evalExprStack.toString());
evalExprStack.push((VarSlot) operand);
return (VarSlot) operand;
}
Expand All @@ -413,8 +413,8 @@ protected VarSlot pushEvalOperand(Operand operand) {

protected VarSlot popEvalOperand() {
var res = evalExprStack.pop();
logger.info("pop eval operand %s",res);
logger.info("pop stack");
logger.debug("pop eval operand %s",res);
logger.debug("pop stack");
OperandSlot.popStack();
if (OperandSlot.getOrdSeq() < 0) {
throw new RuntimeException("un matched pop");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Void visit(VarDeclNode varDeclNode) {

@Override
public Void visit(FuncDeclNode funcDeclNode) {
logger.info("enter %s".formatted(funcDeclNode.toString()));
logger.debug("enter %s".formatted(funcDeclNode.toString()));
methodSymbolStack.push((MethodSymbol) funcDeclNode.getRefSymbol());
/**/
stmts = new ArrayList<>();
Expand Down

0 comments on commit dd4b663

Please sign in to comment.