embed FnDecl inside FunctionSymbol for correct param order

This commit is contained in:
Luna 2019-09-25 10:53:10 -03:00
parent e2cca03d52
commit 6b3d54aed7
2 changed files with 4 additions and 2 deletions

View file

@ -368,8 +368,8 @@ pub fn printContext(ctx: CompilationContext) void {
prettyType(fn_sym.return_type),
);
var param_it = fn_sym.parameters.iterator();
while (param_it.next()) |param_kv| {
for (fn_sym.decl.params.toSlice()) |param| {
var param_kv = fn_sym.parameters.get(param.name.lexeme).?;
std.debug.warn(
"\tparameter {} typ {}\n",
param_kv.key,

View file

@ -33,6 +33,7 @@ pub const SymbolUnderlyingType = union(SymbolUnderlyingTypeEnum) {
// - a return type
// - TODO parameters
pub const FunctionSymbol = struct {
decl: ast.FnDecl,
return_type: SymbolUnderlyingType,
/// Parameters for a function are also a table instead of an ArrayList
@ -153,6 +154,7 @@ pub const CompilationContext = struct {
_ = try self.symbol_table.put(decl.func_name.lexeme, SymbolData{
.Function = FunctionSymbol{
.decl = decl,
.return_type = ret_type,
.parameters = type_map,
.symbols = symbols,