Change how new operators are compiled.

Instead of an instruction that always instantiates an instance,
the "new" is compiled to a method call on the class, followed by a
method call on the (presumably) new instance.

The former lets built-in types like Fn do special stuff instead of
allocating an instance. In particular, it means:

  new Fn { ... }

can just return the block argument.
This commit is contained in:
Bob Nystrom
2014-04-02 17:42:30 -07:00
parent cc56ac4da7
commit a550d6cea4
8 changed files with 49 additions and 33 deletions
+2 -2
View File
@@ -1,13 +1,13 @@
IO.print(Num is Class) // expect: true
IO.print(true is Bool) // expect: true
IO.print((fn 1) is Function) // expect: true
IO.print((fn 1) is Fn) // expect: true
IO.print(123 is Num) // expect: true
IO.print(null is Null) // expect: true
IO.print("s" is String) // expect: true
IO.print(Num is Bool) // expect: false
IO.print(null is Class) // expect: false
IO.print(true is Function) // expect: false
IO.print(true is Fn) // expect: false
IO.print((fn 1) is Num) // expect: false
IO.print("s" is Null) // expect: false
IO.print(123 is String) // expect: false