llvmir some opt

This commit is contained in:
邓智航
2025-12-10 17:58:17 +08:00
commit 84827838e2
103 changed files with 5838 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package frontend.ast.block;
import java.util.ArrayList;
import error.Errors;
import frontend.ast.Node;
import frontend.ast.SyntaxType;
import frontend.lexer.TokenStream;
import frontend.lexer.TokenType;
import frontend.ast.token.TokenNode;
public class Block extends Node {
private boolean isFuncBlock;
public Block(TokenStream ts) {
super(SyntaxType.BLOCK, ts);
isFuncBlock = false;
}
public void parse(Errors errors) {
TokenNode lbrace = new TokenNode(this.ts);
addChild(lbrace);
while (getCurrToken().getType() != TokenType.RBRACE) {
BlockItem bit = new BlockItem(this.ts);
bit.parse(errors);
addChild(bit);
}
TokenNode rbrace = new TokenNode(this.ts);
addChild(rbrace);
}
public ArrayList<BlockItem> getBlockItems() {
ArrayList<BlockItem> blockItems = new ArrayList<>();
for (int i = 0; i < getChildren().size(); i++) {
if (getChild(i) instanceof BlockItem) {
blockItems.add((BlockItem) getChild(i));
}
}
return blockItems;
}
public boolean isFuncBlock() {
return isFuncBlock;
}
public void setIsFuncBlock(boolean isFuncBlock) {
this.isFuncBlock = isFuncBlock;
}
}