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
-3
View File
@@ -150,9 +150,6 @@ typedef enum
// stack.
CODE_RETURN,
// Create a new instance of the receiver, which is assumed to be a class.
CODE_NEW,
// Create a new list with [arg] elements. The top [arg] values on the stack
// are the elements in forward order. Removes the elements and then pushes
// the new list.