Move core.wren to be next to wren_core.wren.inc.

This commit is contained in:
Bob Nystrom
2015-10-17 22:17:10 -07:00
parent e5176607d9
commit 30e7d9e508
7 changed files with 22 additions and 25 deletions

View File

@ -1,9 +0,0 @@
The Wren scripts in this directory get converted to C string literals into files
with a `.wren.inc` extension. Those are then `#include`d into their respective
`.c` files so that the interpreter can load them directly without having to do
any file IO.
The script that does this translation is `util/wren_to_c_string.py`.
When any of the ".wren" files in here are changed, the Makefile automatically
updates the generated C headers.

View File

@ -1,19 +1,24 @@
This contains the Wren source code. It is organized like so:
* `cli`: the source code for the command line interface. This is a custom
exectuable that embeds the VM in itself. Code here handles reading
command-line, running the REPL, loading modules from disc, etc.
* `aux`: the Wren and C source code for the auxiliary modules. These are built
in to the VM and can be used even when you embed the VM in your own
application. But they are also optional and can be compiled out by setting
defines.
* `include`: the public header directory for the VM. If you are embedding the
VM in your own application, you will add this to your include path.
* `cli`: the source code for the command line interface. This is a custom
exectuable that embeds the VM in itself. Code here handles reading
command-line, running the REPL, loading modules from disc, etc.
* `module`: the source code for the built-in modules that come with the CLI.
These modules are written in a mixture of C and Wren and generally use
[libuv][] to implement their underlying functionality.
* `include`: the public header directory for the VM. If you are embedding the
VM in your own application, you will add this to your include path.
* `vm`: the source code for the Wren VM itself. Unlike code in `cli` and
`module`, this has no dependencies on libuv. If you are embedding the VM in
your own application from source, you will compile the files here into your
app.
* `module`: the source code for the built-in modules that come with the CLI.
These modules are written in a mixture of C and Wren and generally use
[libuv][] to implement their underlying functionality.
* `vm`: the source code for the Wren VM itself. Unlike code in `cli` and
`module`, this has no dependencies on libuv. If you are embedding the VM in
your own application from source, you will compile the files here into your
app.
[libuv]: http://libuv.org/

View File

@ -1,4 +1,4 @@
// Generated automatically from src/module/random.wren. Do not edit.
// Generated automatically from src/aux/wren_aux_random.wren. Do not edit.
static const char* randomModuleSource =
"foreign class Random {\n"
" construct new() {\n"

View File

@ -1,4 +1,4 @@
// Generated automatically from builtin/core.wren. Do not edit.
// Generated automatically from src/vm/wren_core.wren. Do not edit.
static const char* coreModuleSource =
"class Bool {}\n"
"class Fiber {}\n"

View File

@ -208,7 +208,7 @@ $(LIBUV): $(LIBUV_DIR)/build/gyp/gyp util/libuv.py
src/aux/wren_aux_%.wren.inc: src/aux/wren_aux_%.wren util/wren_to_c_string.py
@ ./util/wren_to_c_string.py $@ $<
src/vm/wren_%.wren.inc: builtin/%.wren util/wren_to_c_string.py
src/vm/wren_%.wren.inc: src/vm/wren_%.wren util/wren_to_c_string.py
@ ./util/wren_to_c_string.py $@ $<
src/module/%.wren.inc: src/module/%.wren util/wren_to_c_string.py

View File

@ -42,7 +42,8 @@ def main():
wren_source_lines = f.readlines()
module = os.path.splitext(os.path.basename(args.input))[0]
module = module.replace("wren_aux_", "")
module = module.replace("aux_", "")
module = module.replace("wren_", "")
c_source = wren_to_c_string(args.input, wren_source_lines, module)