From 14c6b3e589efdeed524bb15bb4d83c9d1632181a Mon Sep 17 00:00:00 2001 From: sunyinqi0508 Date: Mon, 3 May 2021 17:32:01 +0800 Subject: [PATCH 1/4] Delete launch.json --- .vscode/launch.json | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 53608f3..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - - - { - "type": "java", - "name": "Launch Current File", - "request": "launch", - "classPaths": ["chocopy-ref.jar:target/assignment.jar"], - "mainClass": "chocopy.ChocoPy", - //"args": [ "--pass=rrs", "--test","--dir", "src/test/data/pa3/sample/list_set_element_oob_1.py"], - "args": [ "--pass=rrs", "--test","--dir", "test.py"], - "sourcePaths": [] - } - ] -} \ No newline at end of file From 118303e81f4ed5e1d1ec87f94433011c1e1fc038 Mon Sep 17 00:00:00 2001 From: sunyinqi0508 Date: Mon, 3 May 2021 17:32:10 +0800 Subject: [PATCH 2/4] Delete settings.json --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c5f3f6b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} \ No newline at end of file From 443b61a29fe9ab6bf9194bb1cca4dbf60b05f249 Mon Sep 17 00:00:00 2001 From: sunyinqi0508 Date: Mon, 3 May 2021 17:32:22 +0800 Subject: [PATCH 3/4] Delete conslist --- conslist | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 conslist diff --git a/conslist b/conslist deleted file mode 100644 index f4b83a2..0000000 --- a/conslist +++ /dev/null @@ -1,27 +0,0 @@ - - addi sp, sp, -8 - sw ra, 4(sp) - sw fp, 0(sp) - addi fp, sp, 8 - lw a1, 0(fp) - la a0, $.list$prototype - beqz a1, conslist_done - addi a1, a1, @listHeaderWords - jal alloc2 - lw t0, 0(fp) - sw t0, @.__len__(a0) - slli t1, t0, 2 - add t1, t1, fp - addi t2, a0, @.__elts__ -conslist_1: - lw t3, 0(t1) - sw t3, 0(t2) - addi t1, t1, -4 - addi t2, t2, 4 - addi t0, t0, -1 - bnez t0, conslist_1 -conslist_done: - lw ra, -4(fp) - lw fp, -8(fp) - addi sp, sp, 8 - jr ra \ No newline at end of file From 6890230252edb1029b2d65f7befbef4a50c34850 Mon Sep 17 00:00:00 2001 From: sunyinqi0508 Date: Mon, 3 May 2021 17:33:40 +0800 Subject: [PATCH 4/4] Update CodeGenImpl.java --- src/main/java/chocopy/pa3/CodeGenImpl.java | 26 ++-------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/main/java/chocopy/pa3/CodeGenImpl.java b/src/main/java/chocopy/pa3/CodeGenImpl.java index c3de1f5..06bf552 100644 --- a/src/main/java/chocopy/pa3/CodeGenImpl.java +++ b/src/main/java/chocopy/pa3/CodeGenImpl.java @@ -792,30 +792,8 @@ public class CodeGenImpl extends CodeGenBase @Override public Register analyze(IndexExpr node) { - incSp(1); - Register listObj = node.list.dispatch(this); - backend.emitSW(listObj, FP, -sp_off * wordSize, String.format("Push on stack slot %d", sp_off)); - Register index = node.index.dispatch(this); - Register vacantReg = (index != A0) ? A0 : A1; - - if (node.list.getInferredType().isListType()) { - backend.emitLW(vacantReg, FP, -sp_off * wordSize, String.format("Pop stack slot %d", sp_off)); - - this.d(vacantReg); - return this.a(vacantReg, index, A0, false); - }else{ - this.a(0, vacantReg); - Register a = a(index); - Label ch = generateLocalLabel(); - backend.emitLW(a, vacantReg, getAttrOffset(strClass, "__len__"), "Load attribute: __len__"); - backend.emitBLTU(index, a, ch, "Ensure 0 <= idx < len"); - backend.emitJ(f, "Go to error handler"); - backend.emitLocalLabel(ch, "Index within bounds"); - this.c(index); - Register a2 = this.a(false); - this.a(1); - return a2; - } + //TODO: Not Implemented + return A0; } public Register analyze(MemberExpr node)