Skip to content

Commit

Permalink
Self-spec refactoring
Browse files Browse the repository at this point in the history
Completely remove piqi-boot*.piqi and all the ugliness associated with it.
  • Loading branch information
alavrik committed Oct 8, 2012
1 parent e9a1147 commit 3c80794
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 557 deletions.
2 changes: 1 addition & 1 deletion piqi-erlang/src/piqic_erlang_ext.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ usage() ->
--no-warnings don't print warnings
--trace turn on tracing
--debug <level> debug level; any number greater than 0 turns on debug messages
--noboot don't boot, i.e. don't use boot definitions while processing .piqi
--no-builtin-types don't include built-in type definitions
-C <output directory> specify output directory
--normalize <true|false> normalize identifiers (default: true)
--gen-defaults generate default value constructors for generated types
Expand Down
4 changes: 2 additions & 2 deletions piqi-tools/piqi_convert_cmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ let remove_update_seen l =


let rec get_piqi_deps piqi ~only_imports =
if C.is_boot_piqi piqi
then [] (* boot Piqi is not a dependency *)
if Piqi.is_boot_piqi piqi
then [] (* boot Piqi (a parent of built-in types) is not a dependency *)
else
(* get all includes and includes from all included modules -- only *)
let includes = if only_imports then [piqi] else piqi.P#included_piqi in
Expand Down
10 changes: 2 additions & 8 deletions piqi-tools/piqi_to_proto.ml
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,8 @@ and protoname_import import =


let piqi_to_proto (piqi: T.piqi) ch =
(* implicitly add definitions (aliases) from the boot module to the current
* module *)
let boot_defs =
match !C.piqi_boot with
| None -> []
| Some x -> x. P#resolved_typedef
in
piqi.P#resolved_typedef <- boot_defs @ piqi.P#resolved_typedef;
(* add built-in type definitions to the current module *)
piqi.P#resolved_typedef <- !C.builtin_typedefs @ piqi.P#resolved_typedef;

(* set proto names which are not specified by user *)
protoname_piqi piqi;
Expand Down
14 changes: 1 addition & 13 deletions piqi.org/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,7 @@ PIQI_FILES = \
piqi-lang.piqi


BOOT_PIQI_FILES = piqi-boot.piqi


test: test_boot test_piqi test_piqi_piqi


test_boot:
set -e; \
for i in $(BOOT_PIQI_FILES); \
do \
piqi check --noboot $$i; \
piqi light --noboot $$i; \
done
test: test_piqi test_piqi_piqi


test_piqi:
Expand Down
151 changes: 0 additions & 151 deletions piqi.org/piqi-boot.piqi

This file was deleted.

2 changes: 1 addition & 1 deletion piqic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ debug: dc top

piqi_piqi.ml: $(wildcard *.piqi)
$(PIQICC) $(PIQICC_FLAGS) -o $@.tmp.ml \
--boot piqi-boot.piqi --spec piqi.piqi --lang piqi-lang.piqi --impl piqi-impl.piqi
--spec piqi.piqi --lang piqi-lang.piqi --impl piqi-impl.piqi
$(CAMLP4_O) -o $@ $@.tmp.ml


Expand Down
32 changes: 0 additions & 32 deletions piqic/piqi-boot.erlang.piqi

This file was deleted.

31 changes: 0 additions & 31 deletions piqic/piqi-boot.ocaml.piqi

This file was deleted.

6 changes: 0 additions & 6 deletions piqic/piqi-boot.piqi

This file was deleted.

55 changes: 21 additions & 34 deletions piqic/piqic_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,15 @@ let get_builtin_defs piqi seen_defs def =
(* get all built-in defintions used by (i.e. reacheable from) the module's
* definitions *)
let get_builtin_dependencies piqi =
if !C.piqi_boot = None
then []
else
let rec aux accu root_defs =
let new_builtin_defs = flatmap (get_builtin_defs piqi accu) root_defs in
if new_builtin_defs = []
then accu
else
let accu = uniqq (new_builtin_defs @ accu) in
aux accu new_builtin_defs
in
aux [] piqi.P#resolved_typedef
let rec aux accu root_defs =
let new_builtin_defs = flatmap (get_builtin_defs piqi accu) root_defs in
if new_builtin_defs = []
then accu
else
let accu = uniqq (new_builtin_defs @ accu) in
aux accu new_builtin_defs
in
aux [] piqi.P#resolved_typedef


let piqic_common piqi =
Expand All @@ -115,21 +112,18 @@ let piqic_common piqi =


let rec get_piqi_deps piqi =
if C.is_boot_piqi piqi
then [] (* boot Piqi is not a dependency *)
else
let imports =
List.map (fun x -> some_of x.T.Import#piqi) piqi.P#resolved_import
in
(* get all imports' dependencies recursively *)
let import_deps =
flatmap (fun piqi ->
flatmap get_piqi_deps piqi.P#included_piqi
) imports
in
(* remove duplicate entries *)
let deps = C.uniqq (import_deps @ imports) in
deps @ [piqi]
let imports =
List.map (fun x -> some_of x.T.Import#piqi) piqi.P#resolved_import
in
(* get all imports' dependencies recursively *)
let import_deps =
flatmap (fun piqi ->
flatmap get_piqi_deps piqi.P#included_piqi
) imports
in
(* remove duplicate entries *)
let deps = C.uniqq (import_deps @ imports) in
deps @ [piqi]


let encode_embedded_piqi piqi =
Expand Down Expand Up @@ -162,10 +156,3 @@ let arg__embed_piqi =
"--embed-piqi", Arg.Set flag_embed_piqi,
"embed Piqi modules encoded in binary format in the generated code"


let init () =
(* We have to load embedded Piqi boot modules, because the piqic spec is wider
* than piqicc spec, which means that the default Piqtype.boot_piqi, created
* using the narrower piqicc spec, misses some fields. *)
Piqi.load_embedded_boot_piqi ()

8 changes: 2 additions & 6 deletions piqic/piqic_erlang.ml
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,8 @@ let piqic (piqi: T.piqi) =
Piqic_common.piqic_common piqi;

(* set Erlang names that are not specified by user *)
(match !C.piqi_boot with
| None -> ()
| Some x -> erlname_piqi x
);
erlname_piqi piqi;
erlname_defs !C.builtin_typedefs;

(* set current module's name and type prefix *)
let modname = some_of piqi.P#erlang_module in
Expand All @@ -276,7 +273,7 @@ let piqic (piqi: T.piqi) =
(* set Erlang name for the type "any" *)
if !Piqic_common.is_self_spec
then (
let def = Piqi_db.find_local_typedef piqi "any" in
let def = Piqi_db.find_local_typedef piqi.P#resolved_typedef "any" in
let erl_name = Piqic_erlang_types.typedef_erlname def in
Piqic_erlang_types.any_erlname := erl_name
);
Expand All @@ -291,7 +288,6 @@ let init () =


let piqic_file ifile =
Piqic_common.init ();
init ();

(* load input .piqi file *)
Expand Down
Loading

0 comments on commit 3c80794

Please sign in to comment.