Skip to content

Commit 20e4bd8

Browse files
authored
[interpreter] Directory reorg (#500)
Reorganise directory structure of interpreter sources into smaller parts that match structure of spec document. The prior spec/ directory is split into * `syntax`: the definition of abstract syntax; corresponds to the "Structure" section * `valid`: validation of code and modules; corresponds to the "Validation" section * `exec`: execution and module instantiation; corresponds to the "Execution" section * `binary`: encoding and decoding of binary format; corresponds to the "Binary Format" section * `text`: parsing and printing of text format; corresponds to the "Text Format" section Similarly, the former host/ directory is split into * `script`: abstract syntax and execution of the extended script language * `main`: main program The former host/imports becomes just host/. And finally, the auxiliary directories `findlib`, `jslib`, and `travis` are moved under `meta/`. Also, bump version of the interpreter to 1.0 and update `wast.js`.
1 parent 3099b6f commit 20e4bd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4012
-4454
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ language: c++
22

33
sudo: off
44

5-
install: ./interpreter/travis/install-ocaml.sh
5+
install: ./interpreter/meta/travis/install-ocaml.sh
66

7-
script: ./interpreter/travis/build-test.sh
7+
script: ./interpreter/meta/travis/build-test.sh
88

99
os:
1010
- linux

interpreter/Makefile

+20-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ZIP = $(NAME).zip
1717
JSLIB = wast.js
1818
WINMAKE = winmake.bat
1919

20-
DIRS = util spec text host host/import
20+
DIRS = util syntax binary text valid exec script host main
2121
LIBS = bigarray
2222
FLAGS = -cflags '-w +a-4-27-42-44-45 -warn-error +a'
2323
OCB = ocamlbuild $(FLAGS) $(DIRS:%=-I %) $(LIBS:%=-libs %)
@@ -26,36 +26,48 @@ JS = # set to JS shell command to run JS tests
2626

2727
# Main targets
2828

29-
.PHONY: default opt unopt libopt libunopt all land zip
29+
.PHONY: default opt unopt libopt libunopt jslib all land zip
3030

3131
default: opt
3232
opt: $(OPT)
3333
unopt: $(UNOPT)
3434
libopt: _build/$(LIB).cmx
3535
libunopt: _build/$(LIB).cmo
36+
jslib: $(JSLIB)
3637
all: unopt opt libunopt libopt test
3738
land: all $(WINMAKE)
3839
zip: $(ZIP)
3940

4041

4142
# Building executable
4243

44+
empty =
45+
space = $(empty) $(empty)
46+
comma = ,
47+
48+
.INTERMEDIATE: _tags
49+
_tags:
50+
echo >$@ "true: bin_annot"
51+
echo >>$@ "<{$(subst $(space),$(comma),$(DIRS))}/*.cmx>: for-pack($(PACK))"
52+
4353
$(UNOPT): main.d.byte
4454
mv $< $@
4555

4656
$(OPT): main.native
4757
mv $< $@
4858

4959
.PHONY: main.d.byte main.native
50-
main.d.byte:
60+
main.d.byte: _tags
5161
$(OCB) -quiet $@
5262

53-
main.native:
63+
main.native: _tags
5464
$(OCB) -quiet $@
5565

5666

5767
# Building library
5868

69+
PACK = $(shell echo `echo $(LIB) | sed 's/^\(.\).*$$/\\1/g' | tr [:lower:] [:upper:]``echo $(LIB) | sed 's/^.\(.*\)$$/\\1/g'`)
70+
5971
.INTERMEDIATE: $(LIB).mlpack
6072
$(LIB).mlpack: $(DIRS)
6173
ls $(DIRS:%=%/*.ml*) \
@@ -76,8 +88,8 @@ _build/$(LIB).cmx: $(LIB).mlpack
7688
.PHONY: $(JSLIB)
7789
$(JSLIB): $(UNOPT)
7890
mkdir -p _build/jslib/src
79-
cp jslib/* _build/jslib
80-
cp $(DIRS:%=_build/%/*.ml*) jslib/*.ml _build/jslib/src
91+
cp meta/jslib/* _build/jslib
92+
cp $(DIRS:%=_build/%/*.ml*) meta/jslib/*.ml _build/jslib/src
8193
rm _build/jslib/src/*.ml[^i]
8294
(cd _build/jslib; ./build.sh ../../$@)
8395
@@ -124,7 +136,7 @@ $(ZIP): $(WINMAKE)
124136
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD
125137
126138
clean:
127-
rm -rf _build/jslib wasm.mlpack
139+
rm -rf _build/jslib wasm.mlpack _tags
128140
$(OCB) -clean
129141
130142
@@ -138,7 +150,7 @@ check:
138150
ocamlfind query $(LIBS)
139151
140152
install: _build/$(LIB).cmx _build/$(LIB).cmo
141-
ocamlfind install wasm findlib/META _build/wasm.o \
153+
ocamlfind install wasm meta/findlib/META _build/wasm.o \
142154
$(wildcard _build/$(LIB).cm*) \
143155
$(wildcard $(DIRS:%=%/*.mli))
144156

interpreter/README.md

+14-4

interpreter/_tags

-2
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

interpreter/host/main.ml renamed to interpreter/main/main.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
let name = "wasm"
2-
let version = "0.7"
2+
let version = "1.0"
33

44
let configure () =
55
Import.register (Utf8.decode "spectest") Spectest.lookup;
66
Import.register (Utf8.decode "env") Env.lookup
77

88
let banner () =
9-
print_endline
10-
(name ^ "-" ^ Printf.sprintf "0x%lX" Encode.version ^
11-
" " ^ version ^ " reference interpreter")
9+
print_endline (name ^ " " ^ version ^ " reference interpreter")
1210

1311
let usage = "Usage: " ^ name ^ " [option] [file ...]"
1412

File renamed without changes.

interpreter/jslib/build.sh renamed to interpreter/meta/jslib/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ echo 1>&2 ==== Compiling ====
7474
BSPATH=`which bsb`
7575
BPATH=`dirname $BSPATH`/../lib/js
7676
echo 1>&2 BSPATH = $BSPATH
77-
bsb || exit 1
77+
bsb.exe || exit 1
7878
cp `dirname $BSPATH`/../lib/js/*.js lib/js/src
7979

8080
echo 1>&2 ==== Linking full version ====
File renamed without changes.

interpreter/travis/build-test.sh renamed to interpreter/meta/travis/build-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -x
55

66
# Move to a location relative to the script so it runs
77
# from anywhere.
8-
cd $(dirname ${BASH_SOURCE[0]})/..
8+
cd $(dirname ${BASH_SOURCE[0]})/../..
99

1010
export PATH=$PWD/../ocaml/install/bin:$PATH
1111

interpreter/travis/install-ocaml.sh renamed to interpreter/meta/travis/install-ocaml.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
set -e
44

55
# Move to a location relative to the script so it runs
6-
# from anywhere. Go two levels down to get out of interpreter/
6+
# from anywhere. Go three levels down to get out of interpreter/
77
# and into the top-level dir, since we'll run ocamlbuild
88
# inside of interpreter/ and it goes pear-shaped if it
99
# encounters ocaml's own build directory.
10-
cd $(dirname ${BASH_SOURCE[0]})/../..
10+
cd $(dirname ${BASH_SOURCE[0]})/../../..
1111

1212
rm -rf ocaml
1313
mkdir ocaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)