Skip to content

Commit

Permalink
split joxa-compiler into several different namespaces
Browse files Browse the repository at this point in the history
This uses the somewhat new support for mutually recursive namespaces
to split the massive joxa-compiler into a bunch of related
namespaces. It will take sometime to get these optimially organized
but at the very least this makes the compiler itself significantly
more approachable.

Signed-off-by: Jordan Wilberding <diginux@gmail.com>
  • Loading branch information
ericbmerritt committed Oct 19, 2012
1 parent 1f7d721 commit 19277c5
Show file tree
Hide file tree
Showing 76 changed files with 84,316 additions and 78,459 deletions.
3 changes: 0 additions & 3 deletions Makefile
Expand Up @@ -18,9 +18,6 @@ BEAMDIR=$(APPDIR)/ebin

# Bootstrap Directories In Build
JOXA_BOOTSTRAP_DIR=$(abspath .bootstrap)
BOOTSTRAP_LIBDIR=$(JOXA_BOOTSTRAP_DIR)
BOOTSTRAP_APPDIR=$(BOOTSTRAP_LIBDIR)/joxa-$(VSN)
BOOTSTRAP_BEAMDIR=$(BOOTSTRAP_APPDIR)/ebin

# Location of the support makefiles
BUILD_SUPPORT=$(CURDIR)/build-support
Expand Down
46 changes: 46 additions & 0 deletions build-support/bootstrap.mkf
@@ -0,0 +1,46 @@
## -*- mode: Makefile; fill-column: 75; comment-column: 50; -*-
SRCDIR=$(CURDIR)/src
BEAMDIR=$(CURDIR)/ebin
DEPS_DIR=$(CURDIR)/deps
ERL=$(shell which erl)
EBIN_DIRS=$(wildcard $(DEPS_DIR)/*/ebin)
BASE_ERLCFLAGS=$(EBIN_DIRS:%= -pa %)
ERLCFLAGS=$(BASE_ERLCFLAGS) -pa $(BEAMDIR)
ERLFLAGS=-noshell $(ERLCFLAGS)


ASTDIR=$(SRCDIR)/ast
COMP= $(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-compiler' main \
-extra

ASTS=$(ASTDIR)/joxa-cmp-util.ast \
$(ASTDIR)/joxa-cmp-path.ast \
$(ASTDIR)/joxa-cmp-ctx.ast \
$(ASTDIR)/joxa-cmp-peg.ast \
$(ASTDIR)/joxa-cmp-lexer.ast \
$(ASTDIR)/joxa-cmp-ns.ast \
$(ASTDIR)/joxa-cmp-call.ast \
$(ASTDIR)/joxa-cmp-literal.ast \
$(ASTDIR)/joxa-cmp-binary.ast \
$(ASTDIR)/joxa-cmp-special-forms.ast \
$(ASTDIR)/joxa-cmp-case.ast \
$(ASTDIR)/joxa-cmp-spec.ast \
$(ASTDIR)/joxa-cmp-expr.ast \
$(ASTDIR)/joxa-cmp-defs.ast \
$(ASTDIR)/joxa-cmp-joxa-info.ast \
$(ASTDIR)/joxa-cmp-checks.ast \
$(ASTDIR)/joxa-cmp-error-format.ast \
$(ASTDIR)/joxa-cmp-parser.ast \
$(ASTDIR)/joxa-compiler.ast

.PHONY: all

.PRECIOUS: %/.d

all: $(ASTS)

$(ASTDIR)/%.ast: $(SRCDIR)/%.jxa $(BEAMDIR)/jxa_bootstrap.beam
$(ERL) $(ERLFLAGS) -s joxa-compiler main \
-extra --bootstrap --to_ast -o $(ASTDIR) $<
echo "." >> $@
$(ERL) $(ERLFLAGS) -s jxa_bootstrap do_bootstrap $(BEAMDIR) $@ -s init stop
58 changes: 29 additions & 29 deletions build-support/core-build.mkf
@@ -1,8 +1,4 @@
## -*- mode: Makefile; fill-column: 75; comment-column: 50; -*-

LOCAL_DEPS=$(TMPDIR)/deps.tar.gz
GOT_DEPS=$(TMPDIR)/got-em

TEST_EBIN=$(APPDIR)/.eunit
TEST_FLAGS=-pa $(TEST_EBIN)

Expand All @@ -12,14 +8,33 @@ EBIN_DIRS=$(wildcard $(DEPS_DIR)/*/ebin)
BASE_ERLCFLAGS=$(EBIN_DIRS:%= -pa %)
ERLCFLAGS=$(BASE_ERLCFLAGS) -pa $(BEAMDIR)
ERLFLAGS=-noshell $(ERLCFLAGS)

ASTDIR=$(SRCDIR)/ast
BOOTSTRAP_ERLFLAGS=-noshell -pa $(BOOTSTRAP_BEAMDIR) $(BASE_ERLCFLAGS)

BOOTSTRAP_ERLFLAGS=-noshell -pa $(BEAMDIR) $(BASE_ERLCFLAGS)

COMP= $(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-compiler' main \
-extra

SRCBEAMS=$(BEAMDIR)/joxa-compiler.beam \

SRCBEAMS = $(BEAMDIR)/joxa-cmp-util.beam \
$(BEAMDIR)/joxa-cmp-path.beam \
$(BEAMDIR)/joxa-cmp-ctx.beam \
$(BEAMDIR)/joxa-cmp-peg.beam \
$(BEAMDIR)/joxa-cmp-lexer.beam \
$(BEAMDIR)/joxa-cmp-ns.beam \
$(BEAMDIR)/joxa-cmp-call.beam \
$(BEAMDIR)/joxa-cmp-literal.beam \
$(BEAMDIR)/joxa-cmp-binary.beam \
$(BEAMDIR)/joxa-cmp-special-forms.beam \
$(BEAMDIR)/joxa-cmp-case.beam \
$(BEAMDIR)/joxa-cmp-spec.beam \
$(BEAMDIR)/joxa-cmp-expr.beam \
$(BEAMDIR)/joxa-cmp-defs.beam \
$(BEAMDIR)/joxa-cmp-joxa-info.beam \
$(BEAMDIR)/joxa-cmp-checks.beam \
$(BEAMDIR)/joxa-cmp-error-format.beam \
$(BEAMDIR)/joxa-cmp-parser.beam \
$(BEAMDIR)/joxa-compiler.beam \
$(BEAMDIR)/joxa-core.beam \
$(BEAMDIR)/joxa-shell.beam \
$(BEAMDIR)/joxa-records.beam \
Expand All @@ -41,7 +56,7 @@ TESTBEAMS = $(TEST_EBIN)/joxa-test-let-match.beam \
$(TEST_EBIN)/joxa-test-namespace-mutual-recursion.beam \
$(TEST_EBIN)/joxa-test-joxification.beam

.PHONY: all test_bootstrap pre_bootstrap bootstrap clean \
.PHONY: all ootstrap clean \
jxa test build get-deps proper eunit \
cucumber shell bare-escript

Expand All @@ -56,16 +71,9 @@ all: build
@mkdir -p $(@D)
@touch $@

$(BOOTSTRAP_BEAMDIR)/%.beam: $(SRCDIR)/%.erl $(BOOTSTRAP_BEAMDIR)/.d
$(ERLC) $(ERLCFLAGS) -o $(BOOTSTRAP_BEAMDIR) $<

$(BOOTSTRAP_BEAMDIR)/%.beam: $(ASTDIR)/%.ast $(BOOTSTRAP_BEAMDIR)/jxa_bootstrap.beam $(BOOTSTRAP_BEAMDIR)/.d
$(ERL) $(BOOTSTRAP_ERLFLAGS) -s jxa_bootstrap do_bootstrap $@ $< -s init stop

$(BEAMDIR)/joxa-compiler.beam: $(SRCDIR)/joxa-compiler.jxa $(BOOTSTRAP_BEAMDIR)/joxa-compiler.beam
@echo bootstrapping the compiler
$(ERL) $(BOOTSTRAP_ERLFLAGS) -s joxa-compiler main \
-extra --bootstrap -o $(BEAMDIR) $(SRCDIR)/joxa-compiler.jxa
$(BEAMDIR)/%.beam: $(ASTDIR)/%.ast $(BEAMDIR)/jxa_bootstrap.beam $(BEAMDIR)/.d
$(ERL) $(BOOTSTRAP_ERLFLAGS) \
-s jxa_bootstrap do_bootstrap $(BEAMDIR) $< -s init stop

$(BEAMDIR)/%.beam: $(SRCDIR)/%.jxa $(BEAMDIR)/.d $(BEAMDIR)/joxa-compiler.beam
$(COMP) -o $(BEAMDIR) $<
Expand Down Expand Up @@ -116,14 +124,6 @@ bare-escript:

escript: build bare-escript

pre_bootstrap:
## Use the working compiler to build itself
$(ERL) $(ERLFLAGS) -s joxa-compiler main \
-extra --bootstrap -o $(BEAMDIR) $(SRCDIR)/joxa-compiler.jxa
## Have the working compiler output its own core erlang ast
$(ERL) $(ERLFLAGS) -s joxa-compiler main \
-extra --bootstrap --to_ast -o $(ASTDIR) $(SRCDIR)/joxa-compiler.jxa
## copy that ast into an erl file for useful later building
echo "." >> $(ASTDIR)/joxa-compiler.ast

bootstrap: pre_bootstrap clean build test
bootstrap:
make -f $(CURDIR)/build-support/bootstrap.mkf
make

0 comments on commit 19277c5

Please sign in to comment.