1
0
forked from Mirror/wren
Commit Graph

11 Commits

Author SHA1 Message Date
a4ae905384 Introduce Attributes (#962)
* introduce Attributes for classes and methods
2021-04-08 21:30:09 -07:00
c5befa72cf Don't use module import string when loading imported variables.
This is an interim step towards supporting relative imports. Previously,
the IMPORT_VARIABLE instruction had a constant string operand for the
import string of the module to import the variable from. However, with
relative imports, the import string needs to be resolved by the host
all into a canonical import string. At that point, the original import
string in the source is no longer useful.

This changes that to have IMPORT_VARIABLE access the imported ObjModule
directly. It works in two pieces:

1. When a module is compiled, it ends with an END_MODULE instruction.
   That instruction stores the current ObjModule in vm->lastModule.

2. The IMPORT_VARIABLE instruction uses vm->lastModule as the module to
   load the variable from. Since no interesting code can execute between
   when a module body completes and the subsequent IMPORT_VARIABLE
   statements, we know vm->lastModule will be the one we imported.
2018-03-20 06:54:51 -07:00
8d37b20783 Compile imports to actual instructions instead of core library calls. 2017-10-31 15:58:59 -07:00
001db02c81 Remove unused DUP opcode. 2016-03-13 22:11:21 -07:00
b7e189fe11 Desugar import statements to core library calls.
This is simpler than having special opcodes for them. It's also a bit
faster, and gets some non-critical code out of the interpreter loop.

Also, this is good prep work for being able to write some of the module
loading process in Wren to make things more flexible for embedders and
the CLI.
2016-02-26 22:43:54 -08:00
c7cd1fb1ac Track the maximum number of slots each function may use.
This is the first step towards dynamically grown stacks. We don't want
to check for stack overflow on every single push, so we store the max
number of slots a function might need and (in later patches) ensure
at function call time that that many slots are available.
2015-12-13 22:57:40 -08:00
1a27593993 Error if a class tries to inherit from null.
Fix #246.
2015-09-12 10:14:04 -07:00
48bdbc7745 First pass at implementing foreign classes.
Most of the pieces are there:

- You can declare a foreign class.
- It will call your C function to provide an allocator function.
- Whenever a foreign object is created, it calls the allocator.
- Foreign methods can access the foreign bytes of an object.
- Most of the runtime checking is in place for things like subclassing
  foreign classes.

There is still some loose ends to tie up:

- Finalizers are not called.
- Some of the error-handling could be better.
- The GC doesn't track how much memory a marked foreign object uses.
2015-08-15 12:07:53 -07:00
5fb6186d7d Make constructors just methods.
* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
2015-07-10 09:18:22 -07:00
2c95ae2d2e Make "is" just another infix operator.
Thanks, Michel!
2015-06-19 07:58:07 -07:00
a7fafce265 Pull out opcode definitions into an X-macro file. 2015-03-28 09:56:07 -07:00