feat: replace CODE_NEW instruction with instantiate method call for class and Fn

Refactor the 'new' operator compilation to emit a method call to 'instantiate' on the class instead of using a dedicated bytecode instruction. This allows built-in types like Fn to override instantiation behavior, enabling `new Fn { ... }` to return the block argument directly. Remove the CODE_NEW opcode from the VM, compiler, and debug printer, and add native methods `class_instantiate`, `fn_instantiate`, `fn_new`, and `object_instantiate` to handle the new dispatch. Update test files to reflect the renamed `Function` class to `Fn`.
This commit is contained in:
Bob Nystrom
2014-04-03 00:42:30 +00:00
parent c606e93516
commit 81f20caf33
8 changed files with 49 additions and 33 deletions
+1 -1
View File
@@ -428,7 +428,7 @@ class Variable {
// Removes all traces of c from this variable.
removeConstraint(constraint) {
_constraints = _constraints.where(fn (c) c != constraint)
_constraints = _constraints.where { |c| c != constraint }
if (_determinedBy == constraint) _determinedBy = null
}
}