fix: 修复 syscalls 参数类型加载逻辑
- 改进参数类型加载逻辑,确保在默认类型非整型时正确处理 - 优化数组读取和写入内置函数的代码结构,提高可读性 - 调整 generateSyscall 方法注释,统一代码风格
This commit is contained in:
parent
1861d7fe53
commit
b017f384ce
@ -101,20 +101,62 @@ public class CallGenerator implements InstructionGenerator<CallInstruction> {
|
||||
|
||||
// 处理数组读取和写入的内置函数
|
||||
switch (fn) {
|
||||
case "__index_b" -> { generateIndexInstruction(ins, out, slotMap, 'B'); return; }
|
||||
case "__index_s" -> { generateIndexInstruction(ins, out, slotMap, 'S'); return; }
|
||||
case "__index_i" -> { generateIndexInstruction(ins, out, slotMap, 'I'); return; }
|
||||
case "__index_l" -> { generateIndexInstruction(ins, out, slotMap, 'L'); return; }
|
||||
case "__index_f" -> { generateIndexInstruction(ins, out, slotMap, 'F'); return; }
|
||||
case "__index_d" -> { generateIndexInstruction(ins, out, slotMap, 'D'); return; }
|
||||
case "__index_r" -> { generateIndexInstruction(ins, out, slotMap, 'R'); return; }
|
||||
case "__setindex_b" -> { generateSetIndexInstruction(ins, out, slotMap, 'B'); return; }
|
||||
case "__setindex_s" -> { generateSetIndexInstruction(ins, out, slotMap, 'S'); return; }
|
||||
case "__setindex_i" -> { generateSetIndexInstruction(ins, out, slotMap, 'I'); return; }
|
||||
case "__setindex_l" -> { generateSetIndexInstruction(ins, out, slotMap, 'L'); return; }
|
||||
case "__setindex_f" -> { generateSetIndexInstruction(ins, out, slotMap, 'F'); return; }
|
||||
case "__setindex_d" -> { generateSetIndexInstruction(ins, out, slotMap, 'D'); return; }
|
||||
case "__setindex_r" -> { generateSetIndexInstruction(ins, out, slotMap, 'R'); return; }
|
||||
case "__index_b" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'B');
|
||||
return;
|
||||
}
|
||||
case "__index_s" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'S');
|
||||
return;
|
||||
}
|
||||
case "__index_i" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'I');
|
||||
return;
|
||||
}
|
||||
case "__index_l" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'L');
|
||||
return;
|
||||
}
|
||||
case "__index_f" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'F');
|
||||
return;
|
||||
}
|
||||
case "__index_d" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'D');
|
||||
return;
|
||||
}
|
||||
case "__index_r" -> {
|
||||
generateIndexInstruction(ins, out, slotMap, 'R');
|
||||
return;
|
||||
}
|
||||
case "__setindex_b" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'B');
|
||||
return;
|
||||
}
|
||||
case "__setindex_s" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'S');
|
||||
return;
|
||||
}
|
||||
case "__setindex_i" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'I');
|
||||
return;
|
||||
}
|
||||
case "__setindex_l" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'L');
|
||||
return;
|
||||
}
|
||||
case "__setindex_f" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'F');
|
||||
return;
|
||||
}
|
||||
case "__setindex_d" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'D');
|
||||
return;
|
||||
}
|
||||
case "__setindex_r" -> {
|
||||
generateSetIndexInstruction(ins, out, slotMap, 'R');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认:普通函数调用
|
||||
@ -306,7 +348,9 @@ public class CallGenerator implements InstructionGenerator<CallInstruction> {
|
||||
throw new IllegalStateException("[CallGenerator] 未找到参数槽位");
|
||||
}
|
||||
char t = out.getSlotType(slot);
|
||||
if (t == '\0') t = defaultType;
|
||||
if (t == '\0' || (t == 'I' && defaultType != 'I')) {
|
||||
t = defaultType;
|
||||
}
|
||||
out.emit(OpHelper.opcode(t + "_LOAD") + " " + slot);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user