Retoor software development Projects Research SearchXNG
Register Sign In

17 lines
307 B
Plaintext
Raw Normal View History

feat: add optimized field load/store instructions for direct method access Introduce CODE_LOAD_FIELD_THIS and CODE_STORE_FIELD_THIS opcodes that bypass receiver stack operations when field access occurs directly within a method body. Refactor field() compiler to emit these faster instructions when compiler->methodName is set, and extract loadThis() helper to correctly resolve 'this' in nested functions. Update VM interpreter with dedicated dispatch cases that read receiver from frame->stackStart instead of popping, and add debug disassembly support. Add test cases for field closure capture and nested class field isolation, removing related TODO comments.
2013-12-23 20:17:40 +01:00
class Foo {
new { _field = "Foo field" }
closeOverGet {
return fn { return _field }
}
closeOverSet {
return fn { _field = "new value" }
}
}
var foo = new Foo
IO.write(foo.closeOverGet.call) // expect: Foo field
foo.closeOverSet.call
IO.write(foo.closeOverGet.call) // expect: new value
Reference in New Issue Copy Permalink
b72a42eedd
wren/test/field/closure.wren
Response time: 37ms
Mail Licenses API