Skip to content

Commit

Permalink
Memory: Invert offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenart12 committed Mar 26, 2023
1 parent 89e2f24 commit c4f8de3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions prev23/src/prev23/phase/memory/MemEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class MemScope {
public int depth = 0;
public long locals_size = 0;
public long args_size = 0;
public long params_size = -8;
public long params_size = 8;
public HashMap<String, AstNameDecl> exported_names = new HashMap<>();

private MemScope() {}
Expand Down Expand Up @@ -83,12 +83,14 @@ public void add_access(AstMemDecl decl) {
var access_depth = Math.max(0, depth);

if (decl instanceof AstParDecl) {
params_size -= mem_size;
access = new MemRelAccess(mem_size, params_size, access_depth);
} else {
params_size += mem_size;
} else if (decl instanceof AstVarDecl) {
locals_size -= mem_size;
access = new MemRelAccess(mem_size, locals_size, access_depth);

if (decl instanceof AstVarDecl || !(type instanceof SemRec))
} else if (decl instanceof AstCmpDecl) {
access = new MemRelAccess(mem_size, locals_size, access_depth);
if (!(type instanceof SemRec))
locals_size += mem_size;
}
}
Expand Down

0 comments on commit c4f8de3

Please sign in to comment.