Gabriel Scherer
688f6aa653
recursive module units: really use stateful storage
...
The previous implementation used a pervasive store passed as
a parameter of the interpreter configuration/state. This approach
worked correctly for (recursive) module/unit definitions:
dereferencing accesses to an aliased functor are made in the
current-time unit store, rather than through the (partly
uninitialized) alias-definition-time store. But it is defeated by
functors, that close over their definition-time environment: their
application results in modules evaluated in the alias-definition-time
environment, which miss module definitions.
See the testcase tests/functor-units-dependency.
2020-11-24 14:38:53 +01:00
Gabriel Scherer
1b6fe1bcae
add a failing testcase
2020-11-24 14:38:53 +01:00
Gabriel Scherer
8670dcae7a
add a minimal test framework
2020-11-24 14:38:53 +01:00
Gabriel Scherer
b3e3858553
add a minimal command-line interface -- through environment variables
2020-11-24 14:38:53 +01:00
Gabriel Scherer
70655bf514
readable failure messages should not be debug-mode-only features
2020-11-24 14:38:53 +01:00
Gabriel Scherer
3083bd1fe9
more primitives used in the compiler
2020-11-24 14:38:53 +01:00
Gabriel Scherer
9bbf49d906
support object-oriented features
...
We need to support the object-oriented code that can be found in the
native backend.
2020-11-24 14:38:53 +01:00
Gabriel Scherer
b89e68967c
fix value_compare
2020-11-24 14:38:53 +01:00
Gabriel Scherer
82c8451a59
[minor] turn mdl_val into a record
2020-11-24 14:38:53 +01:00
Gabriel Scherer
aa470f59eb
[minor] better debug on mismatched values
2020-11-24 14:38:53 +01:00
Gabriel Scherer
9f4187d7b6
[minor] better debug on unsupported features
2020-11-24 14:38:53 +01:00
Gabriel Scherer
1909c8f045
more primitives, mirror nativeint handling
2020-11-24 14:38:53 +01:00
Gabriel Scherer
f454d0258b
Interp: files for the native compiler
2020-11-24 14:38:53 +01:00
Gabriel Scherer
8354eb3fbc
Primitives: caml_array_concat
2020-11-24 14:38:53 +01:00
Gabriel Scherer
a864487efc
add indirections in values to allow backpatching semantics for recursive definitions
...
This approach is very noisy because (un)wrapper for mutable references
must be inserted everywhere in the codebase. On the other hand, it is
also type-directed: it is impossible to forget a pointer dereference
and have a type-correct program. Another approach would be to add
a single `Foward of value option ref` constructor to the type of
values, but then code may silently be incorrect if that case is not
handled properly -- it should be traversed silently by all value
inspections.
2020-11-24 14:38:53 +01:00
Gabriel Scherer
7309b8a8a3
[minor] improve Makefile 'run' target
2020-11-24 14:38:53 +01:00
Gabriel Scherer
d5c248273c
[minor] interp.ml: modularize the compiler files definition
2020-11-24 14:38:53 +01:00
Gabriel Scherer
38a486c336
implement %obj_set_field
2020-11-24 14:38:53 +01:00
Gabriel Scherer
9e0f247eec
Makefile: use ocaml-src/stdlib rather than (ocamlc -where)
...
This is necessary to get the Format fixes to un-break the bootstrap.
2020-11-24 14:38:53 +01:00
Gabriel Scherer
f92d987a7c
Makefile: add RUNARGS variable for 'run' target
2020-11-24 14:38:53 +01:00
Gabriel Scherer
67ba30f421
replace the 'ignore' hack by recursive 'module units'
2020-11-24 14:38:53 +01:00
Gabriel Scherer
e49137c64d
introduce `Open flag for module loading
2020-11-24 14:38:53 +01:00
Gabriel Scherer
0e953175a4
factorize env_get_{module,name,constructor}
2020-11-24 14:38:53 +01:00
Gabriel Scherer
db8f1d088b
Makefile: 'run' target for quick testing (and documentation of environment variables)
2020-11-24 14:38:53 +01:00
Gabriel Scherer
48164303b5
[minor] interp.ml: guess module name from filename
2020-11-24 14:38:21 +01:00
Gabriel Scherer
c0ba672d94
reformat
2020-11-24 14:38:21 +01:00
Gabriel Scherer
52ad92701d
[minor] interp.ml: modifiers are not needed anymore
2020-11-24 14:38:21 +01:00
Gabriel Scherer
4a428978a9
complete the standard library for 4.07
2020-11-24 14:38:21 +01:00
Gabriel Scherer
7c63362faf
primitives: caml_sys_isatty
2020-11-24 14:38:21 +01:00
Gabriel Scherer
9cb0563c96
Make the apply_ref forward-reference more local
2020-11-24 14:38:21 +01:00
Gabriel Scherer
b80581d74a
parametrize Eval functions over the primitives
2020-11-24 14:38:21 +01:00
Gabriel Scherer
1b122ba961
primitives: proper treatment of exceptions raised by primitives
2020-11-24 14:38:21 +01:00
Gabriel Scherer
1733ea8dd0
introduce F-expressions for more expressive definition of some primitives
2020-11-24 14:38:21 +01:00
Gabriel Scherer
6ef3f957f0
[minor] dead code removal
2020-11-24 14:38:21 +01:00
Gabriel Scherer
52d0350bb3
move part of interp.ml into a new eval.ml file
2020-11-24 14:38:21 +01:00
Gabriel Scherer
fc42b8fe5b
remove the Primitives.initial_env reference
2020-11-24 14:38:21 +01:00
Gabriel Scherer
14caf64237
Primitives: protect the exn_id reference
2020-11-24 14:38:21 +01:00
Gabriel Scherer
84bb1f9c69
[minor] remove some dead code
2020-11-24 14:38:21 +01:00
Gabriel Scherer
138c83ee02
use a record for the environment
2020-11-24 14:38:21 +01:00
Gabriel Scherer
43180b37e9
get rid of the fmt_ebb_of_string_fct global reference
...
The approach in this patch is slightly less hygienic (we are not
protected against a user-level shadowing of the CamlinternalFormat
module), but also much simpler.
2020-11-24 14:38:21 +01:00
Gabriel Scherer
0094228128
split the code in several modules
2020-11-24 14:38:21 +01:00
Gabriel Scherer
84e2c3f952
another missing primitive
2020-11-24 14:37:00 +01:00
Gabriel Scherer
25dae627e2
improve the debug printing of primitives declarations
...
Instead of doing a debug print at declaration time, unsupported
primitives are now only debug-printed when they are used, right before
failing with an error message.
2020-11-24 14:37:00 +01:00
Gabriel Scherer
d0f5161f22
wrap caml_gc_quick_stat
2020-11-24 14:37:00 +01:00
Gabriel Scherer
c0435ca569
debug: print source location on failure
2020-11-24 14:37:00 +01:00
Gabriel Scherer
92aafefa90
format: limit to 80 columns
2020-11-24 14:37:00 +01:00
Gabriel Scherer
8c53e923b7
propagate locations in environment accesses
2020-11-24 14:37:00 +01:00
Gabriel Scherer
362f4c1948
use ocamlformat for formatting
2020-11-24 14:37:00 +01:00
Gabriel Scherer
d47a97f8cb
configure 'debug' with OCAMLINTERP_DEBUG=[true|false] environment variable
2020-11-24 14:37:00 +01:00
Gabriel Scherer
3919c17fe7
fixup! use environment variables instead of hardcoded filesystem paths
2020-11-24 14:37:00 +01:00