Introduce a procedure type
This commit is contained in:
19
cli/cl.cpp
19
cli/cl.cpp
@ -14,22 +14,29 @@ namespace elna::cli
|
||||
<< ": " << compile_error->what() << std::endl;
|
||||
}
|
||||
|
||||
constexpr std::size_t pointer_size = 4;
|
||||
|
||||
static std::shared_ptr<source::symbol_table> add_builtin_symbols()
|
||||
{
|
||||
source::symbol_table result;
|
||||
std::vector<std::shared_ptr<const source::type>> intrinsic_arguments;
|
||||
|
||||
auto boolean_info = std::make_shared<source::type_info>(source::boolean_type);
|
||||
auto int_info = std::make_shared<source::type_info>(source::int_type);
|
||||
result.enter("Boolean", boolean_info);
|
||||
result.enter("Int", int_info);
|
||||
|
||||
auto writei = std::make_shared<source::intrinsic_info>();
|
||||
writei->parameter_infos.emplace_back(int_info->type());
|
||||
intrinsic_arguments.push_back(int_info->type());
|
||||
auto writei = std::make_shared<source::intrinsic_info>(
|
||||
source::procedure_type{ intrinsic_arguments, pointer_size });
|
||||
result.enter("writei", writei);
|
||||
intrinsic_arguments.clear();
|
||||
|
||||
auto writeb = std::make_shared<source::intrinsic_info>();
|
||||
writeb->parameter_infos.emplace_back(boolean_info->type());
|
||||
intrinsic_arguments.push_back(boolean_info->type());
|
||||
auto writeb = std::make_shared<source::intrinsic_info>(
|
||||
source::procedure_type{ intrinsic_arguments, pointer_size });
|
||||
result.enter("writeb", writeb);
|
||||
intrinsic_arguments.clear();
|
||||
|
||||
return std::make_shared<source::symbol_table>(std::move(result));
|
||||
}
|
||||
@ -53,8 +60,8 @@ namespace elna::cli
|
||||
return 2;
|
||||
}
|
||||
auto global_scope = add_builtin_symbols();
|
||||
source::name_analysis_visitor(global_scope, in_file).visit(ast.get());
|
||||
source::type_analysis_visitor(global_scope, in_file, 4).visit(ast.get());
|
||||
source::name_analysis_visitor(global_scope, in_file, pointer_size).visit(ast.get());
|
||||
source::type_analysis_visitor(global_scope, in_file, pointer_size).visit(ast.get());
|
||||
source::allocator_visitor(global_scope).visit(ast.get());
|
||||
|
||||
source::intermediate_code_generator intermediate_code_generator{ global_scope };
|
||||
|
Reference in New Issue
Block a user