summaryrefslogtreecommitdiff
path: root/src/texec/libtnsl.go
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-11-03 14:02:59 -0400
committerKyle Gunger <kgunger12@gmail.com>2021-11-03 14:02:59 -0400
commit21fbf1493d722af5610370b25223b390ba7edbd0 (patch)
tree12203fdfa3b47fccf37338e8bae229c4d828e705 /src/texec/libtnsl.go
parent92b72f0357c553add6f010626e85268428ad5eb5 (diff)
[EXEC] Refactor, stub
+ Stub code for eval funcs added + Refactor of libtnsl stub
Diffstat (limited to 'src/texec/libtnsl.go')
-rw-r--r--src/texec/libtnsl.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go
index bf5fcd5..c881cea 100644
--- a/src/texec/libtnsl.go
+++ b/src/texec/libtnsl.go
@@ -107,8 +107,8 @@ func topen_file(in TVariable, out *TVariable) {
// tnsl.io.File.close
func tfile_close(file *TVariable) {
- if (*file).Type == "tnsl.io.File" {
- ((*file).Data).(*os.File).Close()
+ if file.Type == "tnsl.io.File" {
+ (file.Data).(*os.File).Close()
}
}
@@ -123,9 +123,12 @@ func tfile_read(file, out *TVariable) {
// tnsl.io.File.write
func tfile_write(file, in *TVariable) {
- b := []byte{1}
+ b := []byte{0}
if in.Data == "uint8" || in.Data == "int8" {
b[0] = (in.Data).(byte)
+ } else {
+ (file.Data).(*os.File).Close()
+ panic(fmt.Sprintf("Failed to write to file, attempted to use unsupported type (%v)\n", out.Type))
}
(file.Data).(*os.File).Write(b)
}