summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtnsl/box/error.tnsl (renamed from libtnsl/box/_vect.tnsl)18
-rw-r--r--libtnsl/box/string.tnsl6
-rw-r--r--libtnsl/box/vector.tnsl2
-rw-r--r--tnslc/compile/compile.tnsl5
4 files changed, 24 insertions, 7 deletions
diff --git a/libtnsl/box/_vect.tnsl b/libtnsl/box/error.tnsl
index 52e6444..d536012 100644
--- a/libtnsl/box/_vect.tnsl
+++ b/libtnsl/box/error.tnsl
@@ -18,3 +18,21 @@
WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
EXPRESS OR IMPLIED
#/
+
+;enum ERROR_CODE [uint] {
+ OUT_OF_RANGE
+}
+
+;struct Error {
+ String msg,
+ uint code,
+ ~void data
+}
+
+/; method Error
+ /; Error (String msg, uint code)
+ ;self.msg = msg
+ ;self.code = code
+ ;self.data = null
+ ;/
+;/ \ No newline at end of file
diff --git a/libtnsl/box/string.tnsl b/libtnsl/box/string.tnsl
index 70b2c2a..d661676 100644
--- a/libtnsl/box/string.tnsl
+++ b/libtnsl/box/string.tnsl
@@ -19,14 +19,14 @@
EXPRESS OR IMPLIED
#/
-;raw enum TEXT_ENCODING {
+;enum TEXT_ENCODING [uint] {
UTF_8,
UN7_1,
ASCII
}
-;struct String extends Vector (uint8) {
- uint
+;struct String extends Vector(uint8) {
+ uint encoding
}
/; method String
diff --git a/libtnsl/box/vector.tnsl b/libtnsl/box/vector.tnsl
index 065239e..724393f 100644
--- a/libtnsl/box/vector.tnsl
+++ b/libtnsl/box/vector.tnsl
@@ -68,7 +68,7 @@
;/
# Probably not what errors will look like long term, but
# serves as a proof of concept for now
- ;throw Error{"Bad Index"}
+ ;throw Error("Bad index", ERROR_CODE.OUT_OF_RANGE)
;/
/; operator len [uint]
diff --git a/tnslc/compile/compile.tnsl b/tnslc/compile/compile.tnsl
index eb43594..80656e4 100644
--- a/tnslc/compile/compile.tnsl
+++ b/tnslc/compile/compile.tnsl
@@ -16,15 +16,14 @@
/; module compile
# :include "compile/arch/arch.tnsl"
- :include "compile/isa_x86.tnsl"
# :include "compile/comp.tnsl"
;/
;{}{}charp COMMON_ASM = {
"\tret",
- "push %",
- "pop %"
+ "\tpush %",
+ "\tpop %"
}
;struct VType {