forked from alex-eg/sex
make each compiler module one file, built once
A module was a body plus a (module ...) wrapper naming its exports, and the wrapper came in up to three copies: the root's, a test one that exported everything, and sextest's, each recompiling the same body. csc -module makes a file a module by itself, with export forms in its body, so the wrappers are gone. tests/ and tools/sextest/ link what the root built, finding it on the repository path; the tests see what a module exports, and the names only they need are exported as such.
This commit is contained in:
@@ -1,53 +1,21 @@
|
||||
CHICKEN_C = csc
|
||||
|
||||
CSC_FLAGS += -K prefix -static
|
||||
MODULE_FLAGS = -emit-all-import-libraries -module-registration -c
|
||||
|
||||
# The compiler's modules are built once, in the root; their import
|
||||
# libraries and objects are found there through the repository path
|
||||
ROOT = ..
|
||||
export CHICKEN_REPOSITORY_PATH := $(abspath $(ROOT)):$(or $(CHICKEN_REPOSITORY_PATH),$(shell chicken-install -repository))
|
||||
|
||||
MODULES = utils types infer sex-macros reader sex-modules semen sex-fmt-c fmt-c-writer sexc
|
||||
SEX_OBJ = $(MODULES:%=%.o)
|
||||
|
||||
TESTS = basic semen reader fmt-c-writer utils line-directives codegen encapsulation args module-path types infer
|
||||
TEST_SRCS = $(TESTS:%=%.scm)
|
||||
|
||||
sex-tests: run.scm $(TEST_SRCS) $(SEX_OBJ)
|
||||
sex-tests: run.scm $(TEST_SRCS) $(MODULES:%=$(ROOT)/%.o)
|
||||
$(CHICKEN_C) $(CSC_FLAGS) run.scm -o sex-tests -link sexc
|
||||
|
||||
#------------------------------------------------------------------
|
||||
|
||||
utils.o: utils.module.scm ../utils.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) utils.module.scm -o utils.o -unit utils
|
||||
|
||||
types.o: types.module.scm ../types.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) types.module.scm -o types.o -unit types
|
||||
|
||||
infer.o: infer.module.scm ../infer.scm types.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) infer.module.scm -o infer.o -unit infer -link types,utils
|
||||
|
||||
sex-macros.o: sex-macros.module.scm ../sex-macros.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) sex-macros.module.scm -o sex-macros.o -unit sex-macros
|
||||
|
||||
reader.o: reader.module.scm ../reader.scm utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) reader.module.scm -o reader.o -unit reader -link utils
|
||||
|
||||
sex-modules.o: sex-modules.module.scm ../sex-modules.scm reader.o types.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) sex-modules.module.scm -o sex-modules.o -unit sex-modules -link reader,types,utils
|
||||
|
||||
semen.o: semen.module.scm ../semen.scm infer.o sex-macros.o sex-modules.o types.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) semen.module.scm -o semen.o -unit semen -link sex-macros,sex-modules,infer,types,utils
|
||||
|
||||
sex-fmt-c.o: ../sex-fmt-c.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) ../sex-fmt-c.scm -o sex-fmt-c.o -unit sex-fmt-c
|
||||
|
||||
fmt-c-writer.o: fmt-c-writer.module.scm ../fmt-c-writer.scm sex-fmt-c.o types.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) fmt-c-writer.module.scm -o fmt-c-writer.o -unit fmt-c-writer -link sex-fmt-c,types,utils
|
||||
|
||||
sexc.o: sexc.module.scm infer.o types.o ../sexc.scm fmt-c-writer.o sex-macros.o sex-modules.o reader.o semen.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) sexc.module.scm -o sexc.o -unit sexc -link fmt-c-writer,sex-macros,sex-modules,reader,semen,infer,types,utils
|
||||
|
||||
clean:
|
||||
rm -f $(SEX_OBJ)
|
||||
rm -f *.import.scm
|
||||
rm -f *.link
|
||||
rm -f sex-tests
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
(module fmt-c-writer
|
||||
*
|
||||
"../fmt-c-writer.scm")
|
||||
@@ -1,45 +0,0 @@
|
||||
(module infer
|
||||
(;; The IR
|
||||
tvar?
|
||||
tvar-id
|
||||
tvar-classes
|
||||
tvar-rigid?
|
||||
fresh-tvar
|
||||
fresh-rigid-tvar
|
||||
|
||||
prim-type? prim-name prim-quals make-prim
|
||||
ptr-type? ptr-target ptr-quals make-ptr
|
||||
array-type? array-elt array-size make-array-type
|
||||
fn-type? fn-ret fn-args fn-variadic? make-fn-type
|
||||
agg-type? agg-kind agg-name agg-spelling agg-quals make-agg
|
||||
alias-type? alias-name alias-expansion alias-quals make-alias
|
||||
unknown-type? the-unknown-type
|
||||
|
||||
resolve
|
||||
underlying
|
||||
c-primitive?
|
||||
type-quals
|
||||
free-tvars
|
||||
decay
|
||||
|
||||
;; The boundary
|
||||
parse-type
|
||||
unparse-type
|
||||
|
||||
;; Constraints
|
||||
register-class!
|
||||
add-instance!
|
||||
entails?
|
||||
default-tvar!
|
||||
default-type-variables!
|
||||
|
||||
;; Unification
|
||||
unify
|
||||
|
||||
;; Type schemes
|
||||
scheme? scheme-vars scheme-constraints scheme-type
|
||||
make-scheme
|
||||
generalize
|
||||
instantiate
|
||||
substitute)
|
||||
"../infer.scm")
|
||||
@@ -1,3 +0,0 @@
|
||||
(module reader
|
||||
*
|
||||
"../reader.scm")
|
||||
@@ -1,2 +0,0 @@
|
||||
(module semen *
|
||||
"../semen.scm")
|
||||
@@ -1,3 +0,0 @@
|
||||
(module sex-macros
|
||||
*
|
||||
"../sex-macros.scm")
|
||||
@@ -1,3 +0,0 @@
|
||||
(module sex-modules
|
||||
*
|
||||
"../sex-modules.scm")
|
||||
@@ -1,3 +0,0 @@
|
||||
(module sexc
|
||||
*
|
||||
"../sexc.scm")
|
||||
@@ -1,50 +0,0 @@
|
||||
(module types
|
||||
(add-struct
|
||||
add-union
|
||||
add-enum
|
||||
add-typedef
|
||||
add-define
|
||||
|
||||
type-match
|
||||
type-pattern-matches?
|
||||
map-fields
|
||||
|
||||
add-sum!
|
||||
get-sum
|
||||
add-constructor!
|
||||
get-constructor
|
||||
variant-fields
|
||||
reset-declarations!
|
||||
|
||||
add-spec!
|
||||
get-spec
|
||||
spec-parameter
|
||||
spec-methods
|
||||
add-realization!
|
||||
realizes?
|
||||
normalize-fields
|
||||
|
||||
add-method!
|
||||
get-method
|
||||
qualify-op
|
||||
ops-key
|
||||
|
||||
add-name-type!
|
||||
get-name-type
|
||||
type-of
|
||||
current-type-of
|
||||
get-return-type
|
||||
|
||||
get-type-info
|
||||
get-tag-info
|
||||
get-fields
|
||||
get-underlying-type
|
||||
|
||||
type-head?
|
||||
named-arg?
|
||||
named-arg-type
|
||||
arglist-types
|
||||
strip-pub
|
||||
array-bound?
|
||||
array-element-type)
|
||||
"../types.scm")
|
||||
@@ -1,3 +0,0 @@
|
||||
(module utils
|
||||
*
|
||||
"../utils.scm")
|
||||
Reference in New Issue
Block a user