fix(sem)修正上一次提交的语法错误

feature/sem
mxr 2 weeks ago
parent d1f2efa4ae
commit d175189193

@ -208,7 +208,7 @@ void SymbolTable::registerBuiltinFunctions() {
Symbol getint;
getint.name = "getint";
getint.kind = SymbolKind::Function;
getint.type = Type::GetFunctionType(Type::GetInt32Type(), {}); // 无参数
getint.type = ir::Type::GetFunctionType(ir::Type::GetInt32Type(), {}); // 无参数
getint.param_types = {};
getint.scope_level = 0;
getint.is_builtin = true;
@ -218,7 +218,7 @@ void SymbolTable::registerBuiltinFunctions() {
Symbol getfloat;
getfloat.name = "getfloat";
getfloat.kind = SymbolKind::Function;
getfloat.type = Type::GetFunctionType(Type::GetFloatType(), {});
getfloat.type = ir::Type::GetFunctionType(ir::Type::GetFloatType(), {});
getfloat.param_types = {};
getfloat.scope_level = 0;
getfloat.is_builtin = true;
@ -228,40 +228,40 @@ void SymbolTable::registerBuiltinFunctions() {
Symbol getch;
getch.name = "getch";
getch.kind = SymbolKind::Function;
getch.type = Type::GetFunctionType(Type::GetInt32Type(), {});
getch.type = ir::Type::GetFunctionType(ir::Type::GetInt32Type(), {});
getch.param_types = {};
getch.scope_level = 0;
getch.is_builtin = true;
addSymbol(getch);
// 4. putint: void putint(int)
std::vector<std::shared_ptr<Type>> putint_params = { Type::GetInt32Type() };
std::vector<std::shared_ptr<ir::Type>> putint_params = { ir::Type::GetInt32Type() };
Symbol putint;
putint.name = "putint";
putint.kind = SymbolKind::Function;
putint.type = Type::GetFunctionType(Type::GetVoidType(), putint_params);
putint.type = ir::Type::GetFunctionType(ir::Type::GetVoidType(), putint_params);
putint.param_types = putint_params;
putint.scope_level = 0;
putint.is_builtin = true;
addSymbol(putint);
// 5. putfloat: void putfloat(float)
std::vector<std::shared_ptr<Type>> putfloat_params = { Type::GetFloatType() };
std::vector<std::shared_ptr<ir::Type>> putfloat_params = { ir::Type::GetFloatType() };
Symbol putfloat;
putfloat.name = "putfloat";
putfloat.kind = SymbolKind::Function;
putfloat.type = Type::GetFunctionType(Type::GetVoidType(), putfloat_params);
putfloat.type = ir::Type::GetFunctionType(ir::Type::GetVoidType(), putfloat_params);
putfloat.param_types = putfloat_params;
putfloat.scope_level = 0;
putfloat.is_builtin = true;
addSymbol(putfloat);
// 6. putch: void putch(int)
std::vector<std::shared_ptr<Type>> putch_params = { Type::GetInt32Type() };
std::vector<std::shared_ptr<ir::Type>> putch_params = { ir::Type::GetInt32Type() };
Symbol putch;
putch.name = "putch";
putch.kind = SymbolKind::Function;
putch.type = Type::GetFunctionType(Type::GetVoidType(), putch_params);
putch.type = ir::Type::GetFunctionType(ir::Type::GetVoidType(), putch_params);
putch.param_types = putch_params;
putch.scope_level = 0;
putch.is_builtin = true;
@ -269,11 +269,11 @@ void SymbolTable::registerBuiltinFunctions() {
// 7. getarray: int getarray(int a[])
// 参数类型: int a[] 退化为 int* 即 PtrInt32
std::vector<std::shared_ptr<Type>> getarray_params = { Type::GetPtrInt32Type() };
std::vector<std::shared_ptr<ir::Type>> getarray_params = { ir::Type::GetPtrInt32Type() };
Symbol getarray;
getarray.name = "getarray";
getarray.kind = SymbolKind::Function;
getarray.type = Type::GetFunctionType(Type::GetInt32Type(), getarray_params);
getarray.type = ir::Type::GetFunctionType(ir::Type::GetInt32Type(), getarray_params);
getarray.param_types = getarray_params;
getarray.scope_level = 0;
getarray.is_builtin = true;
@ -281,11 +281,11 @@ void SymbolTable::registerBuiltinFunctions() {
// 8. putarray: void putarray(int n, int a[])
// 参数: int n, int a[] -> 实际类型: int, int*
std::vector<std::shared_ptr<Type>> putarray_params = { Type::GetInt32Type(), Type::GetPtrInt32Type() };
std::vector<std::shared_ptr<ir::Type>> putarray_params = { ir::Type::GetInt32Type(), ir::Type::GetPtrInt32Type() };
Symbol putarray;
putarray.name = "putarray";
putarray.kind = SymbolKind::Function;
putarray.type = Type::GetFunctionType(Type::GetVoidType(), putarray_params);
putarray.type = ir::Type::GetFunctionType(ir::Type::GetVoidType(), putarray_params);
putarray.param_types = putarray_params;
putarray.scope_level = 0;
putarray.is_builtin = true;

Loading…
Cancel
Save