summaryrefslogtreecommitdiff
path: root/libtnsl/src
diff options
context:
space:
mode:
Diffstat (limited to 'libtnsl/src')
-rw-r--r--libtnsl/src/algo/algo.tnsl3
-rw-r--r--libtnsl/src/algo/alloc.tnsl (renamed from libtnsl/src/reflect/dynamic.tnsl)0
-rw-r--r--libtnsl/src/algo/dealloc.tnsl (renamed from libtnsl/src/reflect/method.tnsl)0
-rw-r--r--libtnsl/src/asm/asm.tnsl (renamed from libtnsl/src/reflect/lib.tnsl)9
-rw-r--r--libtnsl/src/bootstrap.tnsl38
-rw-r--r--libtnsl/src/libtnsl.tnsl2
-rw-r--r--libtnsl/src/reflect/dispatch.tnsl (renamed from libtnsl/src/reflect/static.tnsl)0
-rw-r--r--libtnsl/src/reflect/reflect.tnsl6
-rw-r--r--libtnsl/src/reflect/type.tnsl74
-rw-r--r--libtnsl/src/reflect/virtual.tnsl144
10 files changed, 186 insertions, 90 deletions
diff --git a/libtnsl/src/algo/algo.tnsl b/libtnsl/src/algo/algo.tnsl
index 7ddd677..7df9198 100644
--- a/libtnsl/src/algo/algo.tnsl
+++ b/libtnsl/src/algo/algo.tnsl
@@ -21,6 +21,9 @@
/; export module algo
/: include
+ "alloc.tnsl"
+ "dealloc.tnsl"
+
"math"
:/
;/ \ No newline at end of file
diff --git a/libtnsl/src/reflect/dynamic.tnsl b/libtnsl/src/algo/alloc.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/reflect/dynamic.tnsl
+++ b/libtnsl/src/algo/alloc.tnsl
diff --git a/libtnsl/src/reflect/method.tnsl b/libtnsl/src/algo/dealloc.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/reflect/method.tnsl
+++ b/libtnsl/src/algo/dealloc.tnsl
diff --git a/libtnsl/src/reflect/lib.tnsl b/libtnsl/src/asm/asm.tnsl
index 0688e6f..d0da9a6 100644
--- a/libtnsl/src/reflect/lib.tnsl
+++ b/libtnsl/src/asm/asm.tnsl
@@ -19,8 +19,11 @@
EXPRESS OR IMPLIED
#/
-: extern const {}_library _LIB_TABLE
+/## tnsl.asm
-; raw struct _library {
+ Unexported module for internal library use. Bridges
+ the gaps between the main language and assembly for
+ the selected ISA/OS combo.
-} \ No newline at end of file
+#; module asm
+;/ \ No newline at end of file
diff --git a/libtnsl/src/bootstrap.tnsl b/libtnsl/src/bootstrap.tnsl
deleted file mode 100644
index aa36956..0000000
--- a/libtnsl/src/bootstrap.tnsl
+++ /dev/null
@@ -1,38 +0,0 @@
-/##
- Copyright 2021 Kyle Gunger
-
- Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses.
-
- This file may only be used in accordance with one of the two
- licenses. You should have received a copy of each license with
- the source code. In the event that you did not recieve a copy
- of the licenses, they may be found at the following URLs:
-
- CDDL 1.0:
- https://opensource.org/licenses/CDDL-1.0
-
- BSD 3-Clause:
- https://opensource.org/licenses/BSD-3-Clause
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/#
- This file provides a nonstandard entry point for a bootstrap implementation of TNSL.
-
- The reference implementation of the TNSL compiler (written in GOLANG for now), does
- not contain feature complete functionality in the form of pre-compiler directives, which the
- full libts uses for compilation on different operating systems. This version is provided
- so that the reference compiler can produce a functional enough libts to compile the
- full tnslc compiler (written in TNSL).
-
- As such, this entry point must be modified manually to use windows, mac, or linux
- code files, and then will provide a barebones file, stream, and error handeling library
- with nothing else to act as a bootstrap for the compiler. The bootstrap compiler should
- be able to compile the full libts and, in turn, the full compiler.
-#/
-
-/;export module ts
-;/ \ No newline at end of file
diff --git a/libtnsl/src/libtnsl.tnsl b/libtnsl/src/libtnsl.tnsl
index 434e7a4..070bfd2 100644
--- a/libtnsl/src/libtnsl.tnsl
+++ b/libtnsl/src/libtnsl.tnsl
@@ -20,6 +20,8 @@
#/
/;export module tnsl
+ ; const ~void _null = 0x0
+
/: import
"algo"
"box"
diff --git a/libtnsl/src/reflect/static.tnsl b/libtnsl/src/reflect/dispatch.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/reflect/static.tnsl
+++ b/libtnsl/src/reflect/dispatch.tnsl
diff --git a/libtnsl/src/reflect/reflect.tnsl b/libtnsl/src/reflect/reflect.tnsl
index 3c1d583..b3640c2 100644
--- a/libtnsl/src/reflect/reflect.tnsl
+++ b/libtnsl/src/reflect/reflect.tnsl
@@ -24,4 +24,10 @@
Type and method resolution, reflection and other required methods such as is
#; export module reflect
+ /: import
+ "type.tnsl"
+ "virtual.tnsl"
+ "resolver.tnsl"
+ "dispatch.tnsl"
+ :/
;/ \ No newline at end of file
diff --git a/libtnsl/src/reflect/type.tnsl b/libtnsl/src/reflect/type.tnsl
index b36dfc5..7a19b7d 100644
--- a/libtnsl/src/reflect/type.tnsl
+++ b/libtnsl/src/reflect/type.tnsl
@@ -20,53 +20,21 @@
#/
/## tnsl.reflect._type
- Header data which prefixes all non-raw structs.
+ Header data which non-raw structs point to.
Upper limits for classes and libs defined here:
- - Max 2^32 libraries
- - Max 2^16 classes per library
+ - Max 2^16 libraries
+ - Max 2^16 modules/sub-modules per library
+ - Max 2^16 classes per module
- Max 2^8 Generics per class
#/
-; raw struct _type(uint8 N) {
- uint32
- _lib_index,
+; raw struct _type() {
uint16
- _type_index,
+ _library_id,
+ _module_id,
+ _type_id,
- {N}_type
- _generic_list
-}
-
-/## tnsl.reflect._method
- Metadata for methods (can be decoded from library
- symbol tables). Limits for methods defined here:
- - Max 2^8 inputs
- - Max 2^8 outputs
-#/
-; raw struct _method(uint8 I, O) {
- ~{}charp
- name,
-
- {I}_type
- inputs,
- {O}_type
- outputs,
-
- ~void
- address
-}
-
-/## tnsl.reflect._member
- Metadata about struct members
-#/
-; raw struct _member {
- ~{}charp
- name,
-
- uint
- offset,
-
- _type
- _member_type
+ {uint8}_type
+ _generics
}
/## tnsl.reflect._type_addresses
@@ -74,22 +42,30 @@
in a class
#/
; raw struct _type_addresses {
- ~{}uint
- _offsets,
- _super_offsets,
-
~{}_type
_supers,
+
+ ~{}uint
+ _super_offsets,
~{}_method
- _methods
+ _methods,
+
+ ~{}_member
+ _members
}
/; method _type
- /; _is (_type_header base)
+ /; _is (_type base) [bool]
+ ;/
+
+ /; inline _get (_type t, ~void s, _member m) [~void]
+ ;/
+
+ /; inline raw _call (_type t, ~void s, _method m, ~void p)
;/
- /; _get_method ()
+ /; _offset (_type cast) [uint]
;/
;/ \ No newline at end of file
diff --git a/libtnsl/src/reflect/virtual.tnsl b/libtnsl/src/reflect/virtual.tnsl
new file mode 100644
index 0000000..8891905
--- /dev/null
+++ b/libtnsl/src/reflect/virtual.tnsl
@@ -0,0 +1,144 @@
+/##
+ Copyright 2021 Kyle Gunger
+
+ Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses.
+
+ This file may only be used in accordance with one of the two
+ licenses. You should have received a copy of each license with
+ the source code. In the event that you did not recieve a copy
+ of the licenses, they may be found at the following URLs:
+
+ CDDL 1.0:
+ https://opensource.org/licenses/CDDL-1.0
+
+ BSD 3-Clause:
+ https://opensource.org/licenses/BSD-3-Clause
+
+ THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
+ WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
+ EXPRESS OR IMPLIED
+#/
+
+/## _LIB_TABLE
+ The array of library export trees.
+
+ Convention:
+ - index 0 is always reserved for language-specific types + libtnsl
+ - index 0 module 0 represents the fundimental in-built types like int
+#/
+: extern const {}~library _LIB_TABLE
+
+; raw struct library {
+ # Version
+ uint16
+ major,
+ minor,
+ patch
+
+ ~sym_node
+ root_node
+}
+
+/## tnsl.reflect._method
+ Metadata for methods (can be decoded from library
+ symbol tables). Limits for methods defined here:
+ - Max 2^8 inputs
+ - Max 2^8 outputs
+#/
+; raw struct _method {
+ {uint8}charp
+ name,
+
+ {uint8}~_type
+ inputs,
+ outputs,
+
+ ~void
+ address
+}
+
+/## tnsl.reflect._member
+ Metadata about struct members
+#/
+; raw struct _member {
+ {uint8}charp
+ name,
+
+ _type
+ member_type,
+
+ uint
+ byte_offset
+}
+
+/## tnsl.reflect.sym_node
+ Represents a module in a symbol tree
+#/
+; raw struct sym_node {
+ {uint8}charp
+ name,
+
+ uint16
+ id,
+
+ {}~sym_node
+ sub_modules,
+
+ {}~sym_type
+ sub_types
+}
+
+/## tnsl.reflect.sym_type
+ Represents a type in a symbol tree
+#/
+; raw struct sym_type {
+ {uint8}charp
+ name,
+
+ {uint8}~sym_type
+ super_types,
+
+}
+
+###############################
+# Traverse the Library Tree #
+###############################
+
+/; get_sym_node (~sym_node root, uint16 mod_id) [~sym_node]
+ /;loop (root != null)
+ /; loop (uint16 sub = 0; sub < len `root.sub_modules) [sub++]
+ /; if (mod_id < `root.sub_modules{sub}.id)
+ /; if (sub == 0)
+ ; return null
+ ;/
+ ;root = `root.sub_modules{sub - 1}
+ ; continue 1
+ ;; else if (mod_id == `root.sub_modules{sub}.id)
+ ; return `root.sub_modules{sub}
+ ;/
+ ;/
+
+ ; break
+ ;/
+
+ ; return null
+;/
+
+/; get_sym_node (uint16 lib_id, mod_id) [~sym_node]
+
+ ;~library lib = _LIB_TABLE{lib_id}
+
+ ;return get_sym_node(`lib.root_node, mod_id)
+;/
+
+/; get_sym_type(uint16 lib_id, mod_id, typ_id) [~sym_type]
+
+ ;~library lib = _LIB_TABLE{lib_id}
+ ;~sym_node mod = get_sym_node(`lib.root_node, mod_id)
+
+ ;return `mod.sub_types{typ_id}
+;/
+
+/; get_sym_type(`const {}charp path) [~sym_type]
+
+;/ \ No newline at end of file