diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57_[Changes]/shelved.patch
new file mode 100644
index 0000000..65c7a83
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57_[Changes]/shelved.patch
@@ -0,0 +1,40 @@
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {\r\n "lastFilter": {\r\n "state": "OPEN",\r\n "assignee": "Robert-M-Lucas"\r\n }\r\n}\r\n \r\n \r\n \r\n {\r\n "selectedUrlAndAccountId": {\r\n "url": "https://github.com/Robert-M-Lucas/whython-8.git",\r\n "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"\r\n }\r\n}\r\n \r\n \r\n \r\n \r\n \r\n \r\n {\r\n "customColor": "",\r\n "associatedIndex": 4\r\n}\r\n \r\n \r\n \r\n \r\n \r\n {\r\n "keyToString": {\r\n "Cargo.Run whython-8.executor": "Run",\r\n "RunOnceActivity.OpenProjectViewOnStart": "true",\r\n "RunOnceActivity.ShowReadmeOnStart": "true",\r\n "RunOnceActivity.rust.reset.selective.auto.import": "true",\r\n "Shell Script.Test Asm.executor": "Run",\r\n "git-widget-placeholder": "master",\r\n "ignore.virus.scanning.warn.message": "true",\r\n "last_opened_file_path": "/home/robertlucas/RustroverProjects/whython-8/src/root/builtin/types",\r\n "node.js.detected.package.eslint": "true",\r\n "node.js.detected.package.tslint": "true",\r\n "node.js.selected.package.eslint": "(autodetect)",\r\n "node.js.selected.package.tslint": "(autodetect)",\r\n "nodejs_package_manager_path": "npm",\r\n "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",\r\n "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",\r\n "org.rust.first.attach.projects": "true",\r\n "settings.editor.selected.configurable": "preferences.keymap",\r\n "vue.rearranger.settings.migration": "true"\r\n }\r\n}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1714088144106\r\n \r\n \r\n 1714088144106\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1714089790504\r\n \r\n \r\n \r\n 1714089790504\r\n \r\n \r\n \r\n 1717349672242\r\n \r\n \r\n \r\n 1717349672242\r\n \r\n \r\n \r\n 1717355914137\r\n \r\n \r\n \r\n 1717355914137\r\n \r\n \r\n \r\n 1717432257327\r\n \r\n \r\n \r\n 1717432257327\r\n \r\n \r\n \r\n 1717432916642\r\n \r\n \r\n \r\n 1717432916642\r\n \r\n \r\n \r\n 1717434442792\r\n \r\n \r\n \r\n 1717434442792\r\n \r\n \r\n \r\n 1717469659146\r\n \r\n \r\n \r\n 1717469659146\r\n \r\n \r\n \r\n 1717473113692\r\n \r\n \r\n \r\n 1717473113692\r\n \r\n \r\n \r\n 1717473365560\r\n \r\n \r\n \r\n 1717473365560\r\n \r\n \r\n \r\n 1717562697947\r\n \r\n \r\n \r\n 1717562697947\r\n \r\n \r\n \r\n 1717570846946\r\n \r\n \r\n \r\n 1717570846946\r\n \r\n \r\n \r\n 1717572031837\r\n \r\n \r\n \r\n 1717572031837\r\n \r\n \r\n \r\n 1717578308406\r\n \r\n \r\n \r\n 1717578308406\r\n \r\n \r\n \r\n 1717598684770\r\n \r\n \r\n \r\n 1717598684770\r\n \r\n \r\n \r\n 1717599815108\r\n \r\n \r\n \r\n 1717599815108\r\n \r\n \r\n \r\n 1717614243407\r\n \r\n \r\n \r\n 1717614243407\r\n \r\n \r\n \r\n 1717614696137\r\n \r\n \r\n \r\n 1717614696137\r\n \r\n \r\n \r\n 1717677552390\r\n \r\n \r\n \r\n 1717677552390\r\n \r\n \r\n \r\n 1717684897421\r\n \r\n \r\n \r\n 1717684897422\r\n \r\n \r\n \r\n 1717705529640\r\n \r\n \r\n \r\n 1717705529640\r\n \r\n \r\n \r\n 1717769943602\r\n \r\n \r\n \r\n 1717769943602\r\n \r\n \r\n \r\n 1717794101530\r\n \r\n \r\n \r\n 1717794101530\r\n \r\n \r\n \r\n 1717794233364\r\n \r\n \r\n \r\n 1717794233364\r\n \r\n \r\n \r\n 1717794747334\r\n \r\n \r\n \r\n 1717794747334\r\n \r\n \r\n \r\n 1717819316020\r\n \r\n \r\n \r\n 1717819316020\r\n \r\n \r\n \r\n 1717826853448\r\n \r\n \r\n \r\n 1717826853448\r\n \r\n \r\n \r\n 1718558711741\r\n \r\n \r\n \r\n 1718558711741\r\n \r\n \r\n \r\n 1718558898901\r\n \r\n \r\n \r\n 1718558898901\r\n \r\n \r\n \r\n 1718636633009\r\n \r\n \r\n \r\n 1718636633009\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/workspace.xml b/.idea/workspace.xml
+--- a/.idea/workspace.xml (revision 8a0512f6660f2d33b86f0854cf19bb43e253cece)
++++ b/.idea/workspace.xml (date 1718805432617)
+@@ -9,11 +9,6 @@
+
+
+
+-
+-
+-
+-
+-
+
+
+
+@@ -41,7 +36,7 @@
+
+ {
+ "selectedUrlAndAccountId": {
+- "url": "https://github.com/Robert-M-Lucas/whython-8.git",
++ "url": "https://github.com/Robert-M-Lucas/whython-8",
+ "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"
+ }
+ }
+@@ -199,6 +194,8 @@
+
+
+
++
++
+
+
+
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57__Changes_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57__Changes_.xml
new file mode 100644
index 0000000..bf263bc
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_19_06_2024_14_57__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15_[Changes]/shelved.patch
new file mode 100644
index 0000000..4c9aca0
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15_[Changes]/shelved.patch
@@ -0,0 +1,85 @@
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n {\r\n "lastFilter": {\r\n "state": "OPEN",\r\n "assignee": "Robert-M-Lucas"\r\n }\r\n}\r\n \r\n \r\n \r\n {\r\n "selectedUrlAndAccountId": {\r\n "url": "https://github.com/Robert-M-Lucas/whython-8.git",\r\n "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"\r\n }\r\n}\r\n \r\n \r\n \r\n \r\n \r\n \r\n {\r\n "customColor": "",\r\n "associatedIndex": 4\r\n}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1714088144106\r\n \r\n \r\n 1714088144106\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1714089790504\r\n \r\n \r\n \r\n 1714089790504\r\n \r\n \r\n \r\n 1717349672242\r\n \r\n \r\n \r\n 1717349672242\r\n \r\n \r\n \r\n 1717355914137\r\n \r\n \r\n \r\n 1717355914137\r\n \r\n \r\n \r\n 1717432257327\r\n \r\n \r\n \r\n 1717432257327\r\n \r\n \r\n \r\n 1717432916642\r\n \r\n \r\n \r\n 1717432916642\r\n \r\n \r\n \r\n 1717434442792\r\n \r\n \r\n \r\n 1717434442792\r\n \r\n \r\n \r\n 1717469659146\r\n \r\n \r\n \r\n 1717469659146\r\n \r\n \r\n \r\n 1717473113692\r\n \r\n \r\n \r\n 1717473113692\r\n \r\n \r\n \r\n 1717473365560\r\n \r\n \r\n \r\n 1717473365560\r\n \r\n \r\n \r\n 1717562697947\r\n \r\n \r\n \r\n 1717562697947\r\n \r\n \r\n \r\n 1717570846946\r\n \r\n \r\n \r\n 1717570846946\r\n \r\n \r\n \r\n 1717572031837\r\n \r\n \r\n \r\n 1717572031837\r\n \r\n \r\n \r\n 1717578308406\r\n \r\n \r\n \r\n 1717578308406\r\n \r\n \r\n \r\n 1717598684770\r\n \r\n \r\n \r\n 1717598684770\r\n \r\n \r\n \r\n 1717599815108\r\n \r\n \r\n \r\n 1717599815108\r\n \r\n \r\n \r\n 1717614243407\r\n \r\n \r\n \r\n 1717614243407\r\n \r\n \r\n \r\n 1717614696137\r\n \r\n \r\n \r\n 1717614696137\r\n \r\n \r\n \r\n 1717677552390\r\n \r\n \r\n \r\n 1717677552390\r\n \r\n \r\n \r\n 1717684897421\r\n \r\n \r\n \r\n 1717684897422\r\n \r\n \r\n \r\n 1717705529640\r\n \r\n \r\n \r\n 1717705529640\r\n \r\n \r\n \r\n 1717769943602\r\n \r\n \r\n \r\n 1717769943602\r\n \r\n \r\n \r\n 1717794101530\r\n \r\n \r\n \r\n 1717794101530\r\n \r\n \r\n \r\n 1717794233364\r\n \r\n \r\n \r\n 1717794233364\r\n \r\n \r\n \r\n 1717794747334\r\n \r\n \r\n \r\n 1717794747334\r\n \r\n \r\n \r\n 1717819316020\r\n \r\n \r\n \r\n 1717819316020\r\n \r\n \r\n \r\n 1717826853448\r\n \r\n \r\n \r\n 1717826853448\r\n \r\n \r\n \r\n 1718558711741\r\n \r\n \r\n \r\n 1718558711741\r\n \r\n \r\n \r\n 1718558898901\r\n \r\n \r\n \r\n 1718558898901\r\n \r\n \r\n \r\n 1718636633009\r\n \r\n \r\n \r\n 1718636633009\r\n \r\n \r\n \r\n 1718798005819\r\n \r\n \r\n \r\n 1718798005819\r\n \r\n \r\n \r\n 1718798188305\r\n \r\n \r\n \r\n 1718798188305\r\n \r\n \r\n \r\n 1718799244388\r\n \r\n \r\n \r\n 1718799244388\r\n \r\n \r\n \r\n 1718803787262\r\n \r\n \r\n \r\n 1718803787262\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/workspace.xml b/.idea/workspace.xml
+--- a/.idea/workspace.xml (revision fb9bb67ba42fe780a02f31da30d3e7e4f4d452c0)
++++ b/.idea/workspace.xml (date 1718921639352)
+@@ -7,23 +7,7 @@
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
++
+
+
+
+@@ -69,28 +53,28 @@
+
+
+
+- {
++ "keyToString": {
++ "Cargo.Run whython-8.executor": "Run",
++ "RunOnceActivity.OpenProjectViewOnStart": "true",
++ "RunOnceActivity.ShowReadmeOnStart": "true",
++ "RunOnceActivity.rust.reset.selective.auto.import": "true",
++ "Shell Script.Test Asm.executor": "Run",
++ "git-widget-placeholder": "master",
++ "ignore.virus.scanning.warn.message": "true",
++ "last_opened_file_path": "/home/robertlucas/RustroverProjects/whython-8/src/root/builtin/types/bool",
++ "node.js.detected.package.eslint": "true",
++ "node.js.detected.package.tslint": "true",
++ "node.js.selected.package.eslint": "(autodetect)",
++ "node.js.selected.package.tslint": "(autodetect)",
++ "nodejs_package_manager_path": "npm",
++ "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
++ "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
++ "org.rust.first.attach.projects": "true",
++ "settings.editor.selected.configurable": "preferences.keymap",
++ "vue.rearranger.settings.migration": "true"
+ }
+-}]]>
++}
+
+
+
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15__Changes_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15__Changes_.xml
new file mode 100644
index 0000000..e071715
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_20_06_2024_23_15__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 130f28a..91270c7 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -8,15 +8,20 @@
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -42,12 +47,12 @@
- {
- "selectedUrlAndAccountId": {
- "url": "https://github.com/Robert-M-Lucas/whython-8.git",
- "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"
+
+}]]>
@@ -63,28 +68,33 @@
- {
- "keyToString": {
- "Cargo.Run whython-8.executor": "Run",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.rust.reset.selective.auto.import": "true",
- "Shell Script.Test Asm.executor": "Run",
- "git-widget-placeholder": "master",
- "ignore.virus.scanning.warn.message": "true",
- "last_opened_file_path": "/home/robertlucas/RustroverProjects/whython-8/src/root/builtin/types/int",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
- "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
- "org.rust.first.attach.projects": "true",
- "settings.editor.selected.configurable": "preferences.keymap",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
diff --git a/Cargo.lock b/Cargo.lock
index 8e2e080..8fcbbaf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -51,28 +51,6 @@ dependencies = [
"windows-sys",
]
-[[package]]
-name = "arr_macro"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c49336e062fa2ae8aca17a2f99c34d9c1a5d30827e8aff1cb4c294f253afe992"
-dependencies = [
- "arr_macro_impl",
- "proc-macro-hack",
- "proc-macro-nested",
-]
-
-[[package]]
-name = "arr_macro_impl"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c6368f9ae5c6ec403ca910327ae0c9437b0a85255b6950c90d497e6177f6e5e"
-dependencies = [
- "proc-macro-hack",
- "quote",
- "syn 1.0.109",
-]
-
[[package]]
name = "arrayvec"
version = "0.7.4"
@@ -310,44 +288,6 @@ dependencies = [
"nom",
]
-[[package]]
-name = "paste"
-version = "1.0.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
-
-[[package]]
-name = "pinned-init"
-version = "0.0.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d20d2610806fec7557ff2c210ccc77e68b6e4a74815582cdc63bd35cb3f39cde"
-dependencies = [
- "paste",
- "pinned-init-macro",
-]
-
-[[package]]
-name = "pinned-init-macro"
-version = "0.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "569a3fcf0e6334c6c46c1507f83a99ba30ae9cdc5761bdb2ca40f7eb55138bd4"
-dependencies = [
- "proc-macro2",
- "quote",
-]
-
-[[package]]
-name = "proc-macro-hack"
-version = "0.5.20+deprecated"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
-
-[[package]]
-name = "proc-macro-nested"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
-
[[package]]
name = "proc-macro2"
version = "1.0.85"
@@ -518,7 +458,6 @@ dependencies = [
name = "whython-8"
version = "0.1.0"
dependencies = [
- "arr_macro",
"b-box",
"clap",
"color-print",
@@ -530,7 +469,6 @@ dependencies = [
"nom",
"nom-supreme",
"nom_locate",
- "pinned-init",
"same-file",
"strum",
"strum_macros",
diff --git a/Cargo.toml b/Cargo.toml
index 76fe9ba..733a372 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,8 +23,6 @@ nom-supreme = "0.8.0"
substring = "1.4.5"
derive-getters = "0.4.0"
derive_more = "0.99.17"
-pinned-init = "0.0.7"
-arr_macro = "0.2.1"
[profile.release]
opt-level = 3
diff --git a/build/out.asm b/build/out.asm
index 5827667..4f737c5 100644
--- a/build/out.asm
+++ b/build/out.asm
@@ -5,8 +5,16 @@ section .text
main:
push rbp
mov rbp, rsp
- mov qword [rbp-8], 1
+ mov qword [rbp-16], 12
+ mov rax, rbp
+ add rax, -16
+ mov qword [rbp-8], rax
+ mov qword [rbp-24], 1
mov rax, qword [rbp-8]
+ mov rdx, qword [rbp-24]
+ add qword [rax], rdx
+ mov qword [rbp-32], 1
+ mov rax, qword [rbp-32]
leave
ret
diff --git a/build/out.o b/build/out.o
index 3b268fb..3d25885 100644
Binary files a/build/out.o and b/build/out.o differ
diff --git a/main.why b/main.why
index 1a44ac2..2f10c50 100644
--- a/main.why
+++ b/main.why
@@ -1,4 +1,3 @@
fn main() -> int {
- return 1;
- printi(123);
+
}
diff --git a/src/root/builtin/types/int/mod.rs b/src/root/builtin/types/int/mod.rs
index 4752dbc..4e15521 100644
--- a/src/root/builtin/types/int/mod.rs
+++ b/src/root/builtin/types/int/mod.rs
@@ -12,6 +12,8 @@ use crate::root::builtin::types::int::p_add::IntPAdd;
use crate::root::builtin::types::int::p_sub::{IntAsSub, IntPSub};
use crate::root::builtin::types::int::printi::PrintI;
use crate::root::builtin::types::int::sub::IntSub;
+use crate::root::compiler::compiler_errors::CError;
+use crate::root::errors::evaluable_errors::EvalErrs;
use crate::root::errors::WErr;
use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable;
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature;
@@ -93,7 +95,16 @@ impl Type for IntType {
}
}
LiteralTokens::Int(value) => {
- if *value < 2147483648 {
+ if *value > i64::MAX as i128 {
+ return WErr::ne(CError::IntLiteralExceedsMax(*value, i64::MAX as i128), literal.location().clone());
+ }
+ if *value < i64::MIN as i128 {
+ return WErr::ne(CError::IntLiteralBelowMin(*value, i64::MAX as i128), literal.location().clone());
+ }
+
+ let value = *value as i64;
+
+ if value < 2147483648 {
format!(" mov qword {location}, {value}\n")
}
else {
diff --git a/src/root/compiler/compile_evaluable.rs b/src/root/compiler/compile_evaluable.rs
index d60136e..0fda73c 100644
--- a/src/root/compiler/compile_evaluable.rs
+++ b/src/root/compiler/compile_evaluable.rs
@@ -6,10 +6,11 @@ use crate::root::compiler::compile_function_call::call_function;
use crate::root::compiler::global_tracker::GlobalTracker;
use crate::root::compiler::local_variable_table::LocalVariableTable;
use crate::root::errors::evaluable_errors::EvalErrs;
-use crate::root::errors::evaluable_errors::EvalErrs::{OpNoReturn, OpWrongReturnType};
+use crate::root::errors::evaluable_errors::EvalErrs::{ExpectedDifferentType, ExpectedFunctionName, ExpectedNotNone, OpNoReturn, OpWrongReturnType};
use crate::root::errors::name_resolver_errors::NRErrors;
use crate::root::errors::WErr;
use crate::root::name_resolver::name_resolvers::{GlobalDefinitionTable, NameResult};
+use crate::root::parser::parse::Location;
use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, EvaluableTokens};
use crate::root::parser::parse_function::parse_operator::{OperatorTokens, PrefixOrInfixEx};
use crate::root::shared::common::{FunctionID, Indirection, TypeRef};
@@ -19,9 +20,10 @@ fn expect_addr(r: (String, Option)) -> Result<(String, Address
Ok((r.0, r.1.unwrap())) // TODO
}
-pub fn set_reference(to_ref: AddressedTypeRef, into: AddressedTypeRef) -> Result {
- if to_ref.type_ref().type_id().with_indirection(to_ref.type_ref().indirection().0 + 1) != *into.type_ref() {
- todo!()
+pub fn set_reference(location: &Location, to_ref: AddressedTypeRef, into: AddressedTypeRef, global_table: &GlobalDefinitionTable) -> Result {
+ let new_type = to_ref.type_ref().type_id().with_indirection(to_ref.type_ref().indirection().0 + 1);
+ if new_type != *into.type_ref() {
+ return WErr::ne(OpWrongReturnType(global_table.get_type_name(into.type_ref()), global_table.get_type_name(&new_type)), location.clone());
}
Ok(format!(" mov rax, rbp
@@ -38,13 +40,13 @@ pub fn compile_evaluable(
global_tracker: &mut GlobalTracker
) -> Result<(String, Option), WErr> {
- let et = et.token();
+ let ets = et.token();
- Ok(match et {
+ Ok(match ets {
EvaluableTokens::Name(name, containing_class) => {
match global_table.resolve_name(name, containing_class.as_ref(), local_variables)? {
- NameResult::Function(_) => return Err(WErr::n(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone())),
- NameResult::Type(_) => return Err(WErr::n(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone())),
+ NameResult::Function(_) => return WErr::ne(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone()),
+ NameResult::Type(_) => return WErr::ne(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone()),
NameResult::Variable(address) => {
let target = global_table.add_local_variable_unnamed_base(address.type_ref().clone(), local_variables);
(copy(*address.local_address(), *target.local_address(), global_table.get_size(target.type_ref())), Some(target))
@@ -64,31 +66,29 @@ pub fn compile_evaluable(
let signature = global_table.get_function_signature(op_fn);
if signature.get().args().len() != 2 {
- return Err(
- WErr::n(
- EvalErrs::InfixOpWrongArgumentCount(
- op.operator().to_str().to_string(),
- global_table.get_type(*lhs_type.type_id()).name().to_string(),
- op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(),
- signature.get().args().len()
- ),
- op.location().clone()
- )
+ return WErr::ne(
+ EvalErrs::InfixOpWrongArgumentCount(
+ op.operator().to_str().to_string(),
+ global_table.get_type(*lhs_type.type_id()).name().to_string(),
+ op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(),
+ signature.get().args().len()
+ ),
+ op.location().clone()
);
}
let return_type = signature.get().return_type().clone();
let return_into = return_type.map(|rt| global_table.add_local_variable_unnamed_base(rt.clone(), local_variables));
- let (c, _) = call_function(fid, op_fn, &[Left(lhs), Left(rhs)], return_into.clone(), global_table, local_variables, global_tracker)?;
+ let (c, _) = call_function(fid, op_fn, op.location(), &op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(), &[Left(lhs), Left(rhs)], return_into.clone(), global_table, local_variables, global_tracker)?;
(c, return_into)
},
EvaluableTokens::PrefixOperator(_, _) => todo!(),
EvaluableTokens::DynamicAccess(_, _) => todo!(), // Accessed methods must be called
- EvaluableTokens::StaticAccess(_, n) => return Err(WErr::n(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone())), // Accessed methods must be called
+ EvaluableTokens::StaticAccess(_, n) => return WErr::ne(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone()), // Accessed methods must be called
EvaluableTokens::FunctionCall(inner, args) => {
- let (slf, ifid) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
+ let (slf, ifid, name) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
let signature = global_table.get_function_signature(ifid);
let return_into = signature.get().return_type().clone().map(|r| global_table.add_local_variable_unnamed_base(r, local_variables));
@@ -104,7 +104,7 @@ pub fn compile_evaluable(
args.iter().for_each(|a| n_args.push(Left(a)));
- let (code, _) = call_function(fid, ifid, &n_args, return_into.clone(), global_table, local_variables, global_tracker)?;
+ let (code, _) = call_function(fid, ifid, et.location(), &name, &n_args, return_into.clone(), global_table, local_variables, global_tracker)?;
(code, return_into)
}
})
@@ -121,16 +121,19 @@ pub fn compile_evaluable_into(
global_tracker: &mut GlobalTracker
) -> Result {
- let et = et.token();
+ let ets = et.token();
- Ok(match et {
+ Ok(match ets {
EvaluableTokens::Name(name, containing_class) => {
match global_table.resolve_name(name, containing_class.as_ref(), local_variables)? {
- NameResult::Function(_) => return Err(WErr::n(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone())),
- NameResult::Type(_) => return Err(WErr::n(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone())),
+ NameResult::Function(_) => return WErr::ne(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone()),
+ NameResult::Type(_) => return WErr::ne(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone()),
NameResult::Variable(address) => {
if address.type_ref() != target.type_ref() {
- todo!() // Mismatched types
+ return WErr::ne(
+ ExpectedDifferentType(global_table.get_type_name(address.type_ref()), global_table.get_type_name(target.type_ref())),
+ name.location().clone()
+ );
}
copy(*address.local_address(), *target.local_address(), global_table.get_size(target.type_ref()))
}
@@ -138,7 +141,7 @@ pub fn compile_evaluable_into(
},
EvaluableTokens::Literal(literal) => {
if target.type_ref().indirection().has_indirection() {
- return Err(WErr::n(EvalErrs::BadIndirection(target.type_ref().indirection().0, 0), literal.location().clone()));
+ return WErr::ne(EvalErrs::BadIndirection(target.type_ref().indirection().0, 0), literal.location().clone());
}
let t = global_table.get_type(*target.type_ref().type_id());
@@ -150,31 +153,29 @@ pub fn compile_evaluable_into(
let signature = global_table.get_function_signature(op_fn);
if signature.get().args().len() != 2 {
- return Err(
- WErr::n(
- EvalErrs::InfixOpWrongArgumentCount(
- op.operator().to_str().to_string(),
- global_table.get_type(*lhs_type.type_id()).name().to_string(),
- op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(),
- signature.get().args().len()
- ),
- op.location().clone()
- )
+ return WErr::ne(
+ EvalErrs::InfixOpWrongArgumentCount(
+ op.operator().to_str().to_string(),
+ global_table.get_type(*lhs_type.type_id()).name().to_string(),
+ op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(),
+ signature.get().args().len()
+ ),
+ op.location().clone()
);
}
match signature.get().return_type() {
None => {
- return Err(WErr::n(OpNoReturn(global_table.get_type_name(target.type_ref())), op.location().clone()))
+ return WErr::ne(OpNoReturn(global_table.get_type_name(target.type_ref())), op.location().clone())
}
Some(rt) => {
if rt != target.type_ref() {
- return Err(WErr::n(OpWrongReturnType(global_table.get_type_name(target.type_ref()), global_table.get_type_name(rt)), op.location().clone()))
+ return WErr::ne(OpWrongReturnType(global_table.get_type_name(target.type_ref()), global_table.get_type_name(rt)), op.location().clone())
}
}
}
- let (c, _) = call_function(fid, op_fn, &[Left(lhs), Left(rhs)], Some(target), global_table, local_variables, global_tracker)?;
+ let (c, _) = call_function(fid, op_fn, et.location(), &op.operator().get_method_name(PrefixOrInfixEx::Infix).unwrap(), &[Left(lhs), Left(rhs)], Some(target), global_table, local_variables, global_tracker)?;
c
},
@@ -183,12 +184,15 @@ pub fn compile_evaluable_into(
if op.operator() == &OperatorTokens::Reference {
let (mut c, val) = compile_evaluable_reference(fid, lhs, local_variables, global_table, global_tracker)?;
- let Some(val) = val else { todo!() };
+ let Some(val) = val else {
+ return WErr::ne(ExpectedNotNone, lhs.location().clone())
+ };
+
if *val.type_ref() != lhs_type {
- todo!()
+ panic!()
}
- c += &set_reference(val, target)?;
+ c += &set_reference(op.location(), val, target, global_table)?;
return Ok(c);
}
@@ -197,37 +201,35 @@ pub fn compile_evaluable_into(
let signature = global_table.get_function_signature(op_fn);
if signature.get().args().len() != 1 {
- return Err(
- WErr::n(
- EvalErrs::InfixOpWrongArgumentCount(
- op.operator().to_str().to_string(),
- global_table.get_type(*lhs_type.type_id()).name().to_string(),
- op.operator().get_method_name(PrefixOrInfixEx::Prefix).unwrap(),
- signature.get().args().len()
- ),
- op.location().clone()
- )
+ return WErr::ne(
+ EvalErrs::InfixOpWrongArgumentCount(
+ op.operator().to_str().to_string(),
+ global_table.get_type(*lhs_type.type_id()).name().to_string(),
+ op.operator().get_method_name(PrefixOrInfixEx::Prefix).unwrap(),
+ signature.get().args().len()
+ ),
+ op.location().clone()
);
}
match signature.get().return_type() {
None => {
- return Err(WErr::n(OpNoReturn(global_table.get_type_name(target.type_ref())), op.location().clone()))
+ return WErr::ne(OpNoReturn(global_table.get_type_name(target.type_ref())), op.location().clone())
}
Some(rt) => {
if rt != target.type_ref() {
- return Err(WErr::n(OpWrongReturnType(global_table.get_type_name(target.type_ref()), global_table.get_type_name(rt)), op.location().clone()))
+ return WErr::ne(OpWrongReturnType(global_table.get_type_name(target.type_ref()), global_table.get_type_name(rt)), op.location().clone())
}
}
}
- let (c, _) = call_function(fid, op_fn, &[Left(lhs)], Some(target), global_table, local_variables, global_tracker)?;
+ let (c, _) = call_function(fid, op_fn, et.location(), &op.operator().get_method_name(PrefixOrInfixEx::Prefix).unwrap(), &[Left(lhs)], Some(target), global_table, local_variables, global_tracker)?;
c
},
EvaluableTokens::DynamicAccess(_, _) => todo!(), // Accessed methods must be called
- EvaluableTokens::StaticAccess(_, n) => return Err(WErr::n(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone())), // Accessed methods must be called
+ EvaluableTokens::StaticAccess(_, n) => return WErr::ne(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone()), // Accessed methods must be called
EvaluableTokens::FunctionCall(inner, args) => {
- let (slf, ifid) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
+ let (slf, ifid, name) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
let mut n_args = if let Some(slf) = slf.as_ref() {
let mut v = Vec::with_capacity(args.len() + 1);
@@ -240,7 +242,7 @@ pub fn compile_evaluable_into(
args.iter().for_each(|a| n_args.push(Left(a)));
- let (code, _) = call_function(fid, ifid, &n_args, Some(target), global_table, local_variables, global_tracker)?;
+ let (code, _) = call_function(fid, ifid, et.location(), &name, &n_args, Some(target), global_table, local_variables, global_tracker)?;
code
}
})
@@ -260,8 +262,8 @@ pub fn compile_evaluable_reference(
Ok(match ets {
EvaluableTokens::Name(name, containing_class) => {
match global_table.resolve_name(name, containing_class.as_ref(), local_variables)? {
- NameResult::Function(_) => return Err(WErr::n(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone())),
- NameResult::Type(_) => return Err(WErr::n(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone())),
+ NameResult::Function(_) => return WErr::ne(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone()),
+ NameResult::Type(_) => return WErr::ne(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone()),
NameResult::Variable(address) => {
(String::new(), Some(address))
}
@@ -271,7 +273,7 @@ pub fn compile_evaluable_reference(
EvaluableTokens::InfixOperator(_, _, _) => compile_evaluable(fid, et, local_variables, global_table, global_tracker)?,
EvaluableTokens::PrefixOperator(_, _) => compile_evaluable(fid, et, local_variables, global_table, global_tracker)?,
EvaluableTokens::DynamicAccess(_, _) => todo!(), // Accessed methods must be called
- EvaluableTokens::StaticAccess(_, n) => return Err(WErr::n(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone())), // Accessed methods must be called
+ EvaluableTokens::StaticAccess(_, n) => return WErr::ne(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone()), // Accessed methods must be called
EvaluableTokens::FunctionCall(_, _) => compile_evaluable(fid, et, local_variables, global_table, global_tracker)?,
})
}
@@ -283,17 +285,17 @@ pub fn compile_evaluable_function_only(
local_variables: &mut LocalVariableTable,
global_table: &mut GlobalDefinitionTable,
global_tracker: &mut GlobalTracker
-) -> Result<(Option, FunctionID), WErr> {
+) -> Result<(Option, FunctionID, String), WErr> {
Ok(match name.token() {
EvaluableTokens::Name(name, containing_class) => {
match global_table.resolve_name(name, containing_class.as_ref(), local_variables)? {
NameResult::Function(fid) => {
- (None, fid)
+ (None, fid, name.name().clone())
}
- _ => todo!(),
+ _ => return WErr::ne(ExpectedFunctionName, name.location().clone()),
}
}
- _ => todo!()
+ _ => return WErr::ne(ExpectedFunctionName, name.location().clone())
})
}
@@ -311,8 +313,8 @@ pub fn compile_evaluable_type_only(
Ok(match et {
EvaluableTokens::Name(name, containing_class) => {
match global_table.resolve_name(name, containing_class.as_ref(), local_variables)? {
- NameResult::Function(_) => return Err(WErr::n(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone())),
- NameResult::Type(_) => return Err(WErr::n(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone())),
+ NameResult::Function(_) => return WErr::ne(EvalErrs::FunctionMustBeCalled(name.name().clone()), name.location().clone()),
+ NameResult::Type(_) => return WErr::ne(EvalErrs::CannotEvalStandaloneType(name.name().clone()), name.location().clone()),
NameResult::Variable(address) => {
address.type_ref().clone()
}
@@ -346,9 +348,9 @@ pub fn compile_evaluable_type_only(
signature.get().return_type().as_ref().unwrap().clone()
},
EvaluableTokens::DynamicAccess(_, _) => todo!(), // Accessed methods must be called
- EvaluableTokens::StaticAccess(_, n) => return Err(WErr::n(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone())), // Accessed methods must be called
+ EvaluableTokens::StaticAccess(_, n) => return WErr::ne(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone()), // Accessed methods must be called
EvaluableTokens::FunctionCall(inner, args) => {
- let (slf, ifid) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
+ let (slf, ifid, _) = compile_evaluable_function_only(fid, inner, local_variables, global_table, global_tracker)?;
let signature = global_table.get_function_signature(ifid);
let return_type = signature.get().return_type().clone().unwrap(); // TODO: Check type
diff --git a/src/root/compiler/compile_function.rs b/src/root/compiler/compile_function.rs
index 9bede5e..5627beb 100644
--- a/src/root/compiler/compile_function.rs
+++ b/src/root/compiler/compile_function.rs
@@ -2,6 +2,7 @@ use crate::root::assembler::assembly_builder::AssemblyBuilder;
use crate::root::builtin::types::bool::BoolType;
use crate::root::builtin::types::int::IntType;
use crate::root::compiler::compile_evaluable::{compile_evaluable_into, compile_evaluable_reference};
+use crate::root::compiler::compiler_errors::CError::{CannotBreak, ExpectedNoReturn, ExpectedReturn, ExpectedReturnType, ExpectedSomeReturn};
use crate::root::compiler::global_tracker::GlobalTracker;
use crate::root::compiler::local_variable_table::LocalVariableTable;
use crate::root::errors::WErr;
@@ -15,7 +16,7 @@ use crate::root::utils::warn;
pub fn compile_function(fid: FunctionID, function: FunctionToken, global_table: &mut GlobalDefinitionTable, global_tracker: &mut GlobalTracker) -> Result {
let mut local_variables = LocalVariableTable::new();
- let (_location, _name, return_type, _, parameters, lines) = function.dissolve();
+ let (_location, end_location, _name, return_type, _, parameters, lines) = function.dissolve();
let return_type = if fid.is_main() { None } else { return_type };
@@ -46,7 +47,8 @@ pub fn compile_function(fid: FunctionID, function: FunctionToken, global_table:
// let stack_size = local_variables.stack_size();
if (return_variable.is_some() || fid.is_main()) && !last_return {
- todo!() // No return
+ let type_ref = return_variable.map(|x| x.type_ref().clone()).unwrap_or_else(|| IntType::id().immediate());
+ return WErr::ne(ExpectedReturn(global_table.get_type_name(&type_ref)), end_location)
}
let final_contents = format!(
@@ -146,7 +148,7 @@ fn recursively_compile_lines(fid: FunctionID, lines: &[LineTokens], return_varia
last_is_return = true;
if fid.is_main() {
if rt.return_value().is_none() {
- todo!()
+ return WErr::ne(ExpectedSomeReturn(global_table.get_type_name(&IntType::id().immediate())), rt.location().clone());
}
let address = global_table.add_local_variable_unnamed_base(TypeRef::new(IntType::id(), Indirection(0)), local_variables);
@@ -155,13 +157,13 @@ fn recursively_compile_lines(fid: FunctionID, lines: &[LineTokens], return_varia
}
else if let Some(return_value) = rt.return_value() {
if return_variable.is_none() {
- todo!()
+ return WErr::ne(ExpectedNoReturn, return_value.location().clone());
}
contents.other(&compile_evaluable_into(fid, return_value, return_variable.clone().unwrap(), local_variables, global_table, global_tracker)?);
}
else if return_variable.is_some() {
- todo!()
+ return WErr::ne(ExpectedSomeReturn(global_table.get_type_name(return_variable.as_ref().unwrap().type_ref())), rt.location().clone());
}
contents.line("leave");
@@ -172,12 +174,12 @@ fn recursively_compile_lines(fid: FunctionID, lines: &[LineTokens], return_varia
}
break;
}
- LineTokens::Break(_) => {
+ LineTokens::Break(bt) => {
if let Some(break_tag) = break_tag {
contents.line(&format!("jmp {break_tag}"));
}
else {
- todo!()
+ return WErr::ne(CannotBreak, bt.location().clone())
}
},
LineTokens::NoOp(et) => {
diff --git a/src/root/compiler/compile_function_call.rs b/src/root/compiler/compile_function_call.rs
index 5f28ab8..788ac6c 100644
--- a/src/root/compiler/compile_function_call.rs
+++ b/src/root/compiler/compile_function_call.rs
@@ -3,10 +3,12 @@ use itertools::Itertools;
use crate::root::assembler::assembly_builder::AssemblyBuilder;
use crate::root::compiler::assembly::utils::{align_16_bytes, align_16_bytes_plus_8, copy};
use crate::root::compiler::compile_evaluable::compile_evaluable_into;
+use crate::root::compiler::compiler_errors::CError::{BadFunctionArgCount, BadFunctionReturn, ExpectedFunctionReturn, ExpectedSomeReturn};
use crate::root::compiler::global_tracker::GlobalTracker;
use crate::root::compiler::local_variable_table::LocalVariableTable;
use crate::root::errors::WErr;
use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable;
+use crate::root::parser::parse::Location;
use crate::root::parser::parse_function::parse_evaluable::EvaluableToken;
use crate::root::shared::common::{AddressedTypeRef, ByteSize, FunctionID};
use crate::root::utils::warn;
@@ -16,6 +18,8 @@ use crate::root::utils::warn;
pub fn call_function(
parent_fid: FunctionID,
fid: FunctionID,
+ location: &Location,
+ name: &str,
arguments: &[Either<&EvaluableToken, &AddressedTypeRef>],
return_address: Option,
global_table: &mut GlobalDefinitionTable,
@@ -32,7 +36,7 @@ pub fn call_function(
let return_into = if let Some(expected_return) = global_table.get_function(fid).0.get().return_type().clone() {
if let Some(return_address) = return_address {
if return_address.type_ref() != &expected_return {
- todo!()
+ return WErr::ne(BadFunctionReturn(global_table.get_type_name(return_address.type_ref()), global_table.get_type_name(&expected_return)), location.clone())
}
Some(return_address)
}
@@ -41,17 +45,19 @@ pub fn call_function(
}
}
else {
- if return_address.is_some() {
- todo!()
+ if let Some(return_address) = return_address {
+ return WErr::ne(ExpectedSomeReturn(global_table.get_type_name(return_address.type_ref())), location.clone())
}
None
};
- // TODO: Check arg lengths
-
let mut args = Vec::new();
let signature_args = global_table.get_function(fid).0.get().args().iter().map(|(_, t)| t.clone()).collect_vec();
+ if signature_args.len() != arguments.len() {
+ return WErr::ne(BadFunctionArgCount(name.to_string(), signature_args.len(), arguments.len()), location.clone());
+ }
+
for (i, a) in arguments.iter().enumerate() {
match a {
Either::Left(eval) => {
@@ -61,7 +67,8 @@ pub fn call_function(
args.push(*into.local_address());
}
Either::Right(addr) => {
- // TODO: Check argument
+ // ! Should only be possible through self usage
+ debug_assert!(addr.type_ref() == &signature_args[i]);
args.push(*addr.local_address());
}
}
@@ -73,11 +80,14 @@ pub fn call_function(
else {
let mut code = AssemblyBuilder::new();
- // TODO: Check args length
let mut args = Vec::new();
let mut size = ByteSize(0);
let signature_args = global_table.get_function(fid).0.get().args().iter().map(|(_, t)| t.clone()).collect_vec();
+ if signature_args.len() != arguments.len() {
+ return WErr::ne(BadFunctionArgCount(name.to_string(), signature_args.len(), arguments.len()), location.clone());
+ }
+
for (i, a) in arguments.iter().enumerate() {
match a {
Either::Left(eval) => {
@@ -88,7 +98,8 @@ pub fn call_function(
args.push(into);
}
Either::Right(addr) => {
- // TODO: Check argument
+ // ! Should only be possible through self usage
+ debug_assert!(addr.type_ref() == &signature_args[i]);
args.push((*addr).clone());
}
}
@@ -132,7 +143,7 @@ pub fn call_function(
let return_addr = if let Some(return_address) = return_address {
if return_addr.is_none() {
- todo!()
+ return WErr::ne(ExpectedFunctionReturn(global_table.get_type_name(return_address.type_ref())), location.clone());
}
code.other(©(*return_addr.as_ref().unwrap().local_address(), *return_address.local_address(), global_table.get_size(return_addr.as_ref().unwrap().type_ref())));
diff --git a/src/root/compiler/compiler_errors.rs b/src/root/compiler/compiler_errors.rs
new file mode 100644
index 0000000..b490c8f
--- /dev/null
+++ b/src/root/compiler/compiler_errors.rs
@@ -0,0 +1,26 @@
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+pub enum CError {
+ #[error("Int literal ({0}) exceeds maximum value ({1}) for type")]
+ IntLiteralExceedsMax(i128, i128),
+ #[error("Int literal ({0}) below minimum value ({1}) for type")]
+ IntLiteralBelowMin(i128, i128),
+ #[error("Expected return ({0})")]
+ ExpectedReturn(String),
+ #[error("Expected return type ({0}) but found ({1})")]
+ ExpectedReturnType(String, String),
+ #[error("Expected return type ({0}), not none")]
+ ExpectedSomeReturn(String),
+ #[error("Expected return with no value")]
+ ExpectedNoReturn,
+ #[error("Cannot break - not in a loop")]
+ CannotBreak,
+ #[error("Expected type ({0}) but function returns ({1})")]
+ BadFunctionReturn(String, String),
+ #[error("Expected type ({0}) but function doesn't return a value")]
+ ExpectedFunctionReturn(String),
+ #[error("Function ({0}) expects ({1}) arguments but found ({2})")]
+ BadFunctionArgCount(String, usize, usize),
+}
+
diff --git a/src/root/compiler/mod.rs b/src/root/compiler/mod.rs
index 29e11a6..bbddb15 100644
--- a/src/root/compiler/mod.rs
+++ b/src/root/compiler/mod.rs
@@ -4,4 +4,5 @@ mod compile_function;
pub mod assembly;
mod compile_evaluable;
pub mod compile_function_call;
-pub mod global_tracker;
\ No newline at end of file
+pub mod global_tracker;
+pub mod compiler_errors;
\ No newline at end of file
diff --git a/src/root/errors/evaluable_errors.rs b/src/root/errors/evaluable_errors.rs
index a617d8c..f01cc2f 100644
--- a/src/root/errors/evaluable_errors.rs
+++ b/src/root/errors/evaluable_errors.rs
@@ -18,5 +18,15 @@ pub enum EvalErrs {
#[error("Expected operation to return type ({0}) but found ({1})")]
OpWrongReturnType(String, String),
#[error("Expected operation to return type ({0}) but found no return")]
- OpNoReturn(String)
+ OpNoReturn(String),
+ #[error("Expected type ({0}) but found ({1})")]
+ ExpectedDifferentType(String, String),
+ #[error("Expected type ({0}) but found none")]
+ ExpectedType(String),
+ #[error("Expected a type but found none")]
+ ExpectedNotNone,
+ #[error("Expected a function name")]
+ ExpectedFunctionName
}
+
+// return Err(WErr::n(OpWrongReturnType(global_table.get_type_name(into.type_ref()), global_table.get_type_name(&new_type)), location.clone()));
\ No newline at end of file
diff --git a/src/root/errors/mod.rs b/src/root/errors/mod.rs
index 80b417e..4fcc2ef 100644
--- a/src/root/errors/mod.rs
+++ b/src/root/errors/mod.rs
@@ -19,11 +19,18 @@ impl WErr {
}
}
- pub fn locationless(error: impl Display) -> WErr {
- WErr {
+ pub fn ne(error: impl Display, location: Location) -> Result {
+ Err(WErr {
+ error: format!("{error}"),
+ location: Some(location)
+ })
+ }
+
+ pub fn locationless(error: impl Display) -> Result {
+ Err(WErr {
error: format!("{error}"),
location: None
- }
+ })
}
}
diff --git a/src/root/name_resolver/name_resolvers.rs b/src/root/name_resolver/name_resolvers.rs
index 05a871f..aa01ab7 100644
--- a/src/root/name_resolver/name_resolvers.rs
+++ b/src/root/name_resolver/name_resolvers.rs
@@ -177,7 +177,7 @@ impl GlobalDefinitionTable {
let (name, containing) = match full_name.token() {
FullNameTokens::Name(n, c) => (n, c),
- _ => Err(WErr::n(NRErrors::ExpectedTypeNotMethodOrAttribute, find_error_point(full_name, full_name.location())))?
+ _ => WErr::ne(NRErrors::ExpectedTypeNotMethodOrAttribute, find_error_point(full_name, full_name.location()))?
};
let name = if name.name() == "Self" && containing.is_some() {
@@ -188,7 +188,7 @@ impl GlobalDefinitionTable {
tree.get_entry(name.name()).map(|val| match val {
NameTreeEntry::Type(t) => Ok(TypeRef::new(*t, *indirection)),
NameTreeEntry::Function(_) => {
- Err(WErr::n(NRErrors::FoundFunctionNotType(name.name().clone()), full_name.location().clone()))
+ WErr::ne(NRErrors::FoundFunctionNotType(name.name().clone()), full_name.location().clone())
}
})
};
@@ -209,10 +209,10 @@ impl GlobalDefinitionTable {
}
if let Some(r) = self.builtin_function_name_table.get(name.name()) {
- return Err(WErr::n(NRErrors::FoundFunctionNotType(name.name().clone()), full_name.location().clone()))
+ return WErr::ne(NRErrors::FoundFunctionNotType(name.name().clone()), full_name.location().clone())
}
- Err(WErr::n(NRErrors::TypeNotFound(name.name().clone()), full_name.location().clone()))
+ WErr::ne(NRErrors::TypeNotFound(name.name().clone()), full_name.location().clone())
}
pub fn get_size(&mut self, t: &TypeRef) -> ByteSize {
@@ -261,7 +261,14 @@ impl GlobalDefinitionTable {
}
pub fn get_type_name(&self, type_ref: &TypeRef) -> String {
- format!("{:&^1$}", self.get_type(*type_ref.type_id()).name(), type_ref.indirection().0)
+ format!("{}{}",
+ unsafe {
+ String::from_utf8_unchecked(
+ vec!['&' as u8; type_ref.indirection().0]
+ )
+ },
+ self.get_type(*type_ref.type_id()).name()
+ )
}
pub fn resolve_name(&mut self, name: &SimpleNameToken, containing_class: Option<&SimpleNameToken>, local_variable_table: &LocalVariableTable) -> Result {
@@ -296,7 +303,7 @@ impl GlobalDefinitionTable {
return Ok(NameResult::Function(*r));
}
- Err(WErr::n(NRErrors::CannotFindName(name.name().clone()), name.location().clone()))
+ WErr::ne(NRErrors::CannotFindName(name.name().clone()), name.location().clone())
}
pub fn get_operator_function(&self, lhs: TypeID, operator: &OperatorToken, kind: PrefixOrInfixEx) -> Result {
@@ -311,10 +318,10 @@ impl GlobalDefinitionTable {
).copied()
}
else {
- Err(WErr::n(match kind {
+ WErr::ne(match kind {
PrefixOrInfixEx::Prefix => NRErrors::OpCantBePrefix(operator.operator().to_str().to_string()),
PrefixOrInfixEx::Infix => NRErrors::OpCantBeInfix(operator.operator().to_str().to_string()),
- }, operator.location().clone()))
+ }, operator.location().clone())
}
}
diff --git a/src/root/name_resolver/resolve.rs b/src/root/name_resolver/resolve.rs
index edd2718..8d86e10 100644
--- a/src/root/name_resolver/resolve.rs
+++ b/src/root/name_resolver/resolve.rs
@@ -14,7 +14,7 @@ pub fn resolve(ast: Vec) -> Result<(GlobalDefinitionTable, HashM
let unprocessed_functions = resolve_names(ast, &mut global_table)?;
if !global_table.has_main() {
- return Err(WErr::locationless(NRErrors::NoMain))
+ return WErr::locationless(NRErrors::NoMain)
}
Ok((global_table, unprocessed_functions))
diff --git a/src/root/name_resolver/resolve_names.rs b/src/root/name_resolver/resolve_names.rs
index cd95369..8460863 100644
--- a/src/root/name_resolver/resolve_names.rs
+++ b/src/root/name_resolver/resolve_names.rs
@@ -90,7 +90,7 @@ pub fn resolve_names(ast: Vec, global_table: &mut GlobalDefiniti
for (e_name, _) in &p_attributes {
if e_name.name() == name.name() {
- return Err(WErr::n(NRErrors::SameAttributeName(name.name().clone()), name.location().clone()));
+ return WErr::ne(NRErrors::SameAttributeName(name.name().clone()), name.location().clone());
}
}
p_attributes.push((name, type_ref))
diff --git a/src/root/name_resolver/resolve_type_sizes.rs b/src/root/name_resolver/resolve_type_sizes.rs
index 6b83006..9b9afaa 100644
--- a/src/root/name_resolver/resolve_type_sizes.rs
+++ b/src/root/name_resolver/resolve_type_sizes.rs
@@ -54,7 +54,7 @@ pub fn resolve_type_sizes(
}
else {
// Type not in unsized_types or type table due to circular definition
- return Err(WErr::n(NRErrors::CircularType(name), attribute_name.location().clone()));
+ return WErr::ne(NRErrors::CircularType(name), attribute_name.location().clone());
}
processed_attributes.push((offset.0, attribute_name, attribute_type));
diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs
index 1b2568b..ede0bef 100644
--- a/src/root/parser/parse.rs
+++ b/src/root/parser/parse.rs
@@ -2,7 +2,7 @@ use std::cmp::min;
use std::ffi::OsStr;
use std::fmt::{Display, Formatter, Write};
use crate::root::parser::parse_toplevel;
-use nom::IResult;
+use nom::{InputTake, IResult};
use nom_locate::LocatedSpan;
use nom_supreme::error::GenericErrorTree;
use std::fs;
@@ -72,7 +72,21 @@ impl LocationTyped {
}
)
}
+ }
+
+ pub fn from_span_end(span: &Span) -> LocationTyped {
+ let (span, _) = &span.take_split(span.len());
+ LocationTyped {
+ error_type: Default::default(),
+ inner_location: Some(
+ InnerLocation {
+ path: span.extra.clone(),
+ offset: span.location_offset(),
+ line: span.location_line(),
+ }
+ )
+ }
}
pub fn path(&self) -> Option<&Rc> {
@@ -105,7 +119,7 @@ impl LocationTyped {
writeln!(f, "{}", cformat!("At:>"))?;
fn fail(f: &mut Formatter<'_>) -> std::fmt::Result {
- write!(f, "Failed to fetch file reference (has the file changed?")
+ write!(f, "Failed to fetch file reference (has the file changed?)")
}
let Ok(file) = fs::read_to_string(location.path.as_path()) else { return fail(f); };
@@ -206,7 +220,7 @@ pub fn parse(path: PathBuf) -> Result, WErr> {
Err(e) => {
// TODO:
println!("{:?}", e);
- return Err(WErr::n(ParseError::ParserErrorsNotImplemented, Location::builtin()));
+ return WErr::ne(ParseError::ParserErrorsNotImplemented, Location::builtin());
}
};
debug_assert!(remaining.is_empty());
diff --git a/src/root/parser/parse_function.rs b/src/root/parser/parse_function.rs
index 80735e8..d30d03e 100644
--- a/src/root/parser/parse_function.rs
+++ b/src/root/parser/parse_function.rs
@@ -26,6 +26,7 @@ pub mod parse_while;
#[derive(Debug, Getters, Dissolve)]
pub struct FunctionToken {
location: Location,
+ end_location: Location,
name: SimpleNameToken,
return_type: Option,
dynamic: bool,
@@ -69,13 +70,18 @@ pub fn parse_function<'a>(s: Span<'a>, allow_self: Option<&SimpleNameToken>) ->
let (s, contents) = default_section(s, '{')?;
+ let end_location = Location::from_span_end(&contents);
+
let (_, lines) = parse_lines(contents, allow_self)?;
+
+
Ok((
s,
FunctionToken {
dynamic: has_self,
location,
+ end_location,
name,
return_type,
parameters,
diff --git a/src/root/parser/parse_function/parse_break.rs b/src/root/parser/parse_function/parse_break.rs
index 5dff7d3..612d8fa 100644
--- a/src/root/parser/parse_function/parse_break.rs
+++ b/src/root/parser/parse_function/parse_break.rs
@@ -1,3 +1,4 @@
+use derive_getters::Getters;
use nom::character::complete::{char};
use nom::Parser;
use nom_supreme::tag::complete::tag;
@@ -6,7 +7,7 @@ use crate::root::parser::parse::{Location, ParseResult, Span};
use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens};
use crate::root::parser::parse_util::discard_ignored;
-#[derive(Debug)]
+#[derive(Debug, Getters)]
pub struct BreakToken {
location: Location,
}
diff --git a/src/root/parser/parse_function/parse_literal.rs b/src/root/parser/parse_function/parse_literal.rs
index 0e1897b..989bfe1 100644
--- a/src/root/parser/parse_function/parse_literal.rs
+++ b/src/root/parser/parse_function/parse_literal.rs
@@ -17,7 +17,7 @@ pub struct LiteralToken {
#[derive(Debug)]
pub enum LiteralTokens {
Bool(bool),
- Int(i64),
+ Int(i128),
}
impl LiteralTokens {
@@ -39,7 +39,7 @@ pub fn parse_literal(s: Span) -> ParseResult {
let (ns, l) = alt((
|x| tag("true")(x).map(|(s, _)| (s, LiteralTokens::Bool(true))),
|x| tag("false")(x).map(|(s, _)| (s, LiteralTokens::Bool(false))),
- |x| nom::character::complete::i64(x).map(|(s, i)| (s, LiteralTokens::Int(i))),
+ |x| nom::character::complete::i128(x).map(|(s, i)| (s, LiteralTokens::Int(i))),
))(s)?;
let l = LiteralToken {
diff --git a/src/root/runner.rs b/src/root/runner.rs
index 1aa827b..c8b696f 100644
--- a/src/root/runner.rs
+++ b/src/root/runner.rs
@@ -6,7 +6,6 @@ use crate::ret_time;
use crate::root::utils::try_run_program;
-#[cfg(target_os = "linux")]
pub fn run(output: &str) {
let time;
ret_time!(time,
@@ -50,7 +49,6 @@ pub fn assemble(output: &str) -> Result<(), ()> {
}
-#[cfg(target_os = "linux")]
pub fn link_gcc(output: &str) -> Result<(), ()> {
if !try_run_program(
"gcc",
diff --git a/src/root/shared/common.rs b/src/root/shared/common.rs
index 943751e..17af132 100644
--- a/src/root/shared/common.rs
+++ b/src/root/shared/common.rs
@@ -71,7 +71,7 @@ impl Display for LocalAddress {
}
}
-#[derive(Getters, Clone, PartialEq)]
+#[derive(Getters, Clone, PartialEq, Debug)]
pub struct TypeRef {
type_id: TypeID,
indirection: Indirection