From 60dcc7c3c013a2492d8db1b04d28cb437921cced Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 22 Nov 2021 21:41:08 -0500 Subject: [PARSE] Remove IsBlock --- src/texec/libtnsl.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/texec') diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go index bff8d48..000af7d 100644 --- a/src/texec/libtnsl.go +++ b/src/texec/libtnsl.go @@ -46,6 +46,8 @@ var ( tFile = TType{Pre: []string{}, T: TArtifact{Path: []string{"tnsl", "io"}, Name: "File"}, Post: []string{}} tString = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: []string{}} tInt = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"int"}, Post: []string{}} + tByte = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: []string{}} + tByteArray = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: []string{}} tFloat = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"float"}, Post: []string{}} tCharp = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: []string{}} tNull = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name: "null"}, Post: []string{}} @@ -143,10 +145,14 @@ func tfile_read(file TVariable) TVariable { // tnsl.io.File.write func tfile_write(file, in TVariable) { - b := []byte{0} - if equateType(file.Type, tFile) && (equateType(in.Type, tCharp) || equateType(in.Type, tInt)) { - b[0] = (in.Data).(byte) - (file.Data).(*os.File).Write(b) + if equateType(file.Type, tFile) { + if equateType(in.Type, tCharp) || equateType(in.Type, tByte) { + b := []byte{0} + b[0] = (in.Data).(byte) + (file.Data).(*os.File).Write(b) + } else if equateType(in.Type, tByteArray) { + (file.Data).(*os.File).Write((in.Data).([]byte)) + } } else { (file.Data).(*os.File).Close() panic(fmt.Sprintf("Failed to write to file, attempted to use unsupported type (%v)\n", in.Type)) -- cgit v1.2.3