diff options
-rw-r--r-- | tnslc/compile/generator.tnsl | 19 | ||||
-rw-r--r-- | tnslc/tnslc.tnsl | 8 | ||||
-rw-r--r-- | tnslc/utils/c_wrap_linux.tnsl (renamed from tnslc/c_wrap_linux.tnsl) | 0 | ||||
-rw-r--r-- | tnslc/utils/c_wrap_windows.tnsl (renamed from tnslc/c_wrap_windows.tnsl) | 0 | ||||
-rw-r--r-- | tnslc/utils/file.tnsl | 17 | ||||
-rw-r--r-- | tnslc/utils/utils.tnsl | 2 |
6 files changed, 27 insertions, 19 deletions
diff --git a/tnslc/compile/generator.tnsl b/tnslc/compile/generator.tnsl index 5d71a05..28a834d 100644 --- a/tnslc/compile/generator.tnsl +++ b/tnslc/compile/generator.tnsl @@ -1,13 +1,16 @@ /; generate (utils.File fin, fout) - ~uint8 fa = fin.path.to_cstr('/') - ~uint8 fb = fout.path.to_cstr('/') - _printf(fa) - _printf(newline) - _printf(fb) - _printf(newline) + fin.open() + fout.create() + + uint8 buf = fin.read() + /; loop (fin.at_end == false && fout.at_end == false) + fout.write(buf) + buf = fin.read() + ;/ + + fin.close() + fout.close() - _delete(fa) - _delete(fb) ;/ diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl index 0123430..84fbdb5 100644 --- a/tnslc/tnslc.tnsl +++ b/tnslc/tnslc.tnsl @@ -1,5 +1,3 @@ -:import "c_wrap_linux.tnsl" - :import "utils/utils.tnsl" :import "compile/compile.tnsl" @@ -17,8 +15,6 @@ usage: ~uint8 char_str = "%c\0" ~uint8 newline = "\n\0" -~uint8 scratch = "asd,efg\0" -~uint8 test = "asd\0" /; main (int argc, ~~uint8 argv) [int] asm "mov r10, rdi" @@ -29,10 +25,6 @@ usage: return 1 ;/ - /; if (compile._in_csv(scratch, test)) - _printf(test) - _printf(newline) - ;/ utils.File fin, fout fin.init(argv{1}) diff --git a/tnslc/c_wrap_linux.tnsl b/tnslc/utils/c_wrap_linux.tnsl index 814ec1c..814ec1c 100644 --- a/tnslc/c_wrap_linux.tnsl +++ b/tnslc/utils/c_wrap_linux.tnsl diff --git a/tnslc/c_wrap_windows.tnsl b/tnslc/utils/c_wrap_windows.tnsl index 577ca25..577ca25 100644 --- a/tnslc/c_wrap_windows.tnsl +++ b/tnslc/utils/c_wrap_windows.tnsl diff --git a/tnslc/utils/file.tnsl b/tnslc/utils/file.tnsl index a33e30c..978f31b 100644 --- a/tnslc/utils/file.tnsl +++ b/tnslc/utils/file.tnsl @@ -5,7 +5,6 @@ struct File { } ~uint8 PT_HANDLE = "Handle: %p\n\0" -uint INVALID_HANDLE = 0xffffffff ~uint8 PARENT_DIR = ".." ~uint8 CURRENT_DIR = "." @@ -43,7 +42,7 @@ uint INVALID_HANDLE = 0xffffffff /; end self.path.end() - /; if (self.handle < INVALID_HANDLE && self.handle != NULL) + /; if (self.handle + 1 !== 0) _close_file(self.handle) self.handle = NULL ;/ @@ -52,17 +51,23 @@ uint INVALID_HANDLE = 0xffffffff /; open ~uint8 p = self.path.to_cstr('/') self.handle = _open_file(p) + /; if (self.handle + 1 == 0) + self.at_end = true + ;/ _delete(p) ;/ /; create ~uint8 p = self.path.to_cstr('/') self.handle = _create_file(p) + /; if (self.handle + 1 == 0) + self.at_end = true + ;/ _delete(p) ;/ /; close - /; if (self.handle !== INVALID_HANDLE && self.handle !== NULL) + /; if (self.handle + 1 !== 0) _close_file(self.handle) self.handle = NULL self.at_end = false @@ -86,4 +91,10 @@ uint INVALID_HANDLE = 0xffffffff ;/ ;/ + /; write_cstr (~uint8 str) + /; loop (self.at_end == false && str` !== 0) [str++] + self.write(str`) + ;/ + ;/ + ;/ diff --git a/tnslc/utils/utils.tnsl b/tnslc/utils/utils.tnsl index fece1da..eab2f8c 100644 --- a/tnslc/utils/utils.tnsl +++ b/tnslc/utils/utils.tnsl @@ -1,3 +1,5 @@ +:import "c_wrap_linux.tnsl" + /; module utils :import "vector.tnsl" |