update: 移除 Optional 字段

This commit is contained in:
zhangxun 2025-06-17 21:47:06 +08:00 committed by Luke
parent 7a9cfc1861
commit 2f8e181b13
2 changed files with 7 additions and 7 deletions

View File

@ -36,7 +36,7 @@ public class IRContext {
/**
* 当前声明变量的类型不在声明变量时为空
*/
private Optional<String> varType;
private String varType;
/**
* 构造一个新的 IRContext并将指定的 IRFunction 与作用域关联
@ -48,7 +48,7 @@ public class IRContext {
this.scope = new IRBuilderScope();
// 关联作用域与 IRFunction以便在声明变量时申请寄存器
this.scope.attachFunction(function);
this.varType = Optional.empty();
this.varType = null;
}
/**
@ -99,7 +99,7 @@ public class IRContext {
*
* @return 当前 declare 的变量类型
*/
public Optional<String> getVarType() {
public String getVarType() {
return varType;
}
@ -108,7 +108,7 @@ public class IRContext {
*
*/
public void setVarType(String type) {
this.varType = Optional.of(type);
this.varType = type;
}
/**
@ -116,6 +116,6 @@ public class IRContext {
*
*/
public void clearVarType() {
this.varType = Optional.empty();
this.varType = null;
}
}

View File

@ -66,8 +66,8 @@ public class ExpressionUtils {
String digits = switch (suffix) {
case 'b','s','l','f','d' -> value.substring(0, value.length() - 1);
default -> {
if (ctx.getVarType().isPresent()) {
final var receiverType = ctx.getVarType().get();
if (ctx.getVarType() != null) {
final var receiverType = ctx.getVarType();
switch (receiverType) {
case "byte" -> suffix = 'b';
case "short" -> suffix = 's';