1
0
forked from Mirror/wren

"IO" -> "System".

Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
This commit is contained in:
Bob Nystrom
2015-09-15 07:46:09 -07:00
parent 66b89a493f
commit 58e4d26648
491 changed files with 3285 additions and 3544 deletions

View File

@ -24,10 +24,10 @@ var minDepth = 4
var maxDepth = 12
var stretchDepth = maxDepth + 1
var start = IO.clock
var start = System.clock
IO.print("stretch tree of depth ", stretchDepth, " check: ",
Tree.new(0, stretchDepth).check)
System.print("stretch tree of depth " + stretchDepth.toString + " check: " +
Tree.new(0, stretchDepth).check.toString)
var longLivedTree = Tree.new(0, maxDepth)
@ -44,10 +44,12 @@ while (depth < stretchDepth) {
check = check + Tree.new(i, depth).check + Tree.new(-i, depth).check
}
IO.print((iterations * 2), " trees of depth ", depth, " check: ", check)
System.print((iterations * 2).toString + " trees of depth " +
depth.toString + " check: " + check.toString)
iterations = iterations / 4
depth = depth + 2
}
IO.print("long lived tree of depth ", maxDepth, " check: ", longLivedTree.check)
IO.print("elapsed: ", (IO.clock - start))
System.print("long lived tree of depth " + maxDepth.toString + " check: " +
longLivedTree.check.toString)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -92,7 +92,7 @@ class Constraint {
chooseMethod(mark)
if (!isSatisfied) {
if (_strength == REQUIRED) {
IO.print("Could not satisfy a required constraint!")
System.print("Could not satisfy a required constraint!")
}
return null
}
@ -102,7 +102,7 @@ class Constraint {
var overridden = out.determinedBy
if (overridden != null) overridden.markUnsatisfied
out.determinedBy = this
if (!ThePlanner.addPropagate(this, mark)) IO.print("Cycle encountered")
if (!ThePlanner.addPropagate(this, mark)) System.print("Cycle encountered")
out.mark = mark
return overridden
}
@ -669,31 +669,31 @@ var projectionTest = Fn.new {|n|
change.call(src, 17)
total = total + dst.value
if (dst.value != 1170) IO.print("Projection 1 failed")
if (dst.value != 1170) System.print("Projection 1 failed")
change.call(dst, 1050)
total = total + src.value
if (src.value != 5) IO.print("Projection 2 failed")
if (src.value != 5) System.print("Projection 2 failed")
change.call(scale, 5)
for (i in 0...n - 1) {
total = total + dests[i].value
if (dests[i].value != i * 5 + 1000) IO.print("Projection 3 failed")
if (dests[i].value != i * 5 + 1000) System.print("Projection 3 failed")
}
change.call(offset, 2000)
for (i in 0...n - 1) {
total = total + dests[i].value
if (dests[i].value != i * 5 + 2000) IO.print("Projection 4 failed")
if (dests[i].value != i * 5 + 2000) System.print("Projection 4 failed")
}
}
var start = IO.clock
var start = System.clock
for (i in 0...40) {
chainTest.call(100)
projectionTest.call(100)
}
IO.print(total)
IO.print("elapsed: ", IO.clock - start)
System.print(total)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -5,8 +5,8 @@ class Fib {
}
}
var start = IO.clock
var start = System.clock
for (i in 1..5) {
IO.print(Fib.get(28))
System.print(Fib.get(28))
}
IO.print("elapsed: ", IO.clock - start)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -2,7 +2,7 @@
var fibers = []
var sum = 0
var start = IO.clock
var start = System.clock
for (i in 0...100000) {
fibers.add(Fiber.new {
@ -12,5 +12,5 @@ for (i in 0...100000) {
}
fibers[0].call()
IO.print(sum)
IO.print("elapsed: ", IO.clock - start)
System.print(sum)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -1,10 +1,10 @@
var list = []
var start = IO.clock
var start = System.clock
for (i in 0...1000000) list.add(i)
var sum = 0
for (i in list) sum = sum + i
IO.print(sum)
IO.print("elapsed: ", IO.clock - start)
System.print(sum)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -1,4 +1,4 @@
var start = IO.clock
var start = System.clock
var map = {}
@ -10,10 +10,10 @@ var sum = 0
for (i in 1..1000000) {
sum = sum + map[i]
}
IO.print(sum)
System.print(sum)
for (i in 1..1000000) {
map.remove(i)
}
IO.print("elapsed: ", IO.clock - start)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -77,7 +77,7 @@ for (animal in animals) {
}
}
var start = IO.clock
var start = System.clock
var map = {}
@ -96,5 +96,5 @@ for (key in keys) {
map.remove(key)
}
IO.print(sum)
IO.print("elapsed: ", IO.clock - start)
System.print(sum)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -28,7 +28,7 @@ class NthToggle is Toggle {
}
}
var start = IO.clock
var start = System.clock
var n = 100000
var val = true
var toggle = Toggle.new(val)
@ -46,7 +46,7 @@ for (i in 0...n) {
val = toggle.activate.value
}
IO.print(toggle.value)
System.print(toggle.value)
val = true
var ntoggle = NthToggle.new(val, 3)
@ -64,5 +64,5 @@ for (i in 0...n) {
val = ntoggle.activate.value
}
IO.print(ntoggle.value)
IO.print("elapsed: ", IO.clock - start)
System.print(ntoggle.value)
System.print("elapsed: " + (System.clock - start).toString)

View File

@ -1,4 +1,4 @@
var start = IO.clock
var start = System.clock
var count = 0
for (i in 1..1000000) {
@ -20,5 +20,5 @@ for (i in 1..1000000) {
"another") count = count + 1
}
IO.print(count)
IO.print("elapsed: ", IO.clock - start)
System.print(count)
System.print("elapsed: " + (System.clock - start).toString)