Move IO into a separate module.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
The Wren scripts in this directory get converted to C string literals and then
|
||||
inserted into their respective .c files so that the interpreter can load them
|
||||
directly without having to do any file IO.
|
||||
|
||||
The script that does this copying is `script/generate_builtins.py`.
|
||||
|
||||
You can invoke using `make builtin`.
|
||||
@@ -0,0 +1,11 @@
|
||||
class List {
|
||||
toString {
|
||||
var result = "["
|
||||
for (i in 0...this.count) {
|
||||
if (i > 0) result = result + ", "
|
||||
result = result + this[i].toString
|
||||
}
|
||||
result = result + "]"
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class IO {
|
||||
static print(obj) {
|
||||
IO.writeString_(obj.toString)
|
||||
IO.writeString_("\n")
|
||||
return obj
|
||||
}
|
||||
|
||||
static write(obj) {
|
||||
IO.writeString_(obj.toString)
|
||||
return obj
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user