Skip to content

Commit 88a104a

Browse files
committed
Fixed out.a webdemo
1 parent 984f99c commit 88a104a

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

interpreter/builtin.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ func quote(args Value, scope *Scope) Value {
196196

197197
func replace(args Value, scope *Scope) Value {
198198
argsList := getArgsList(args)
199-
expression := argsList[0]
199+
expression := interpretExpression(argsList[0], scope)
200200
symbol := argsList[1]
201-
replacement := argsList[2]
201+
replacement := interpretExpression(argsList[2], scope)
202202

203203
if symbol, ok := symbol.(*Symbol); ok {
204204
return subSymbol(expression, symbol, replacement, false)
205205
}
206+
206207
return &Nil{}
207208
}
208209

@@ -343,15 +344,18 @@ func def(args Value, scope *Scope) Value {
343344

344345
func write2Output(args Value, scope *Scope) Value {
345346
argsList := getArgsList(args)
346-
config.OutputFile.WriteString(interpretExpression(argsList[0], scope).String())
347+
message := interpretExpression(argsList[0], scope).String()
348+
if config.OutputEnabled {
349+
config.OutputFile.WriteString(message)
350+
}
347351
return &Nil{}
348352
}
349353

350354

351355
func writeByte2Output(args Value, scope *Scope) Value {
352356
argsList := getArgsList(args)
353357
result := interpretExpression(argsList[0], scope)
354-
if number, ok := result.(*Integer); ok {
358+
if number, ok := result.(*Integer); ok && config.OutputEnabled {
355359
config.OutputFile.Write([]byte{byte(number.Value)})
356360
}
357361
return &Nil{}

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
func main() {
1515
file := "ENVIRONMENT"
1616
code := os.Getenv("GISMO_CODE")
17+
config.OutputEnabled = os.Getenv("NO_OUT") == ""
1718

1819
if code == "" {
1920
// Ensure a file argument is passed
@@ -40,7 +41,7 @@ func main() {
4041
tokens = append(tokens, tokenizer.Tokenize(string(before), file)...)
4142
tokens = append(tokens, &tokenizer.Token{TokenType: tokentype.Newline,})
4243
}
43-
44+
4445
tokens = append(tokens, tokenizer.Tokenize(code, file)...)
4546

4647
if after != nil {

webdemo/main.wasm

443 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)