diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-02-14 15:21:53 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-02-24 20:46:27 -0800 |
| commit | f3ca50c9ca4fd2084cfbc85030ff5ea21e589635 (patch) | |
| tree | 026a63d77c1657e897e33adc6de3fedb7b36a341 /src/etc | |
| parent | be9914625b0cbf5f305c5af3adbc6bc337ae760e (diff) | |
| download | rust-f3ca50c9ca4fd2084cfbc85030ff5ea21e589635.tar.gz rust-f3ca50c9ca4fd2084cfbc85030ff5ea21e589635.zip | |
Encode/decode AST into metadata, re-instantiate inlined items
Diffstat (limited to 'src/etc')
| -rwxr-xr-x | src/etc/gen-astencode | 57 | ||||
| -rw-r--r-- | src/etc/tidy.py | 5 |
2 files changed, 61 insertions, 1 deletions
diff --git a/src/etc/gen-astencode b/src/etc/gen-astencode new file mode 100755 index 00000000000..9e598fafe2f --- /dev/null +++ b/src/etc/gen-astencode @@ -0,0 +1,57 @@ +#!/bin/sh + +M=src/comp/metadata +GEN_TYPES="syntax::ast::item syntax::ast::def middle::typeck::method_origin \ + middle::freevars::freevar_entry syntax::ast::def_id" + +# Find serializer tool: +for S in build/*/stage2/bin/serializer; do + + # Find rustc: + D=$(dirname "$S") + R="${D}/rustc" + if [ ! -x "$R" ]; then + echo "rustc not found or not executable at path '$R'" + exit 1 + fi + + echo "Generating src/comp/metadata/astencode_gen.rs" + + # First, generate dummy fns so that the compiler can type + # everything. + echo "// TEMPORARY DEFINITIONS: re-run gen-astencode" \ + > $M/astencode_gen.rs + for T in $GEN_TYPES; do + echo "fn serialize_${T//::/_}<S>(_s: S, _v: $T) {}" \ + >> $M/astencode_gen.rs + echo "fn deserialize_${T//::/_}<S>(_s: S) -> $T { fail; }" \ + >> $M/astencode_gen.rs + done + + # Generate the real code into a temporary file. + if ! "$S" src/comp/rustc.rc $GEN_TYPES > tmp.$$.rs + then + echo "" + echo "" + echo "****************************************" + echo "* Compilation errors encountered *" + echo "* *" + echo "* Dummy versions of the AST encoder *" + echo "* have been left in astencode_gen.rs. *" + echo "* Fix the compilation errors and rerun *" + echo "* this script to generate the real *" + echo "* versions. *" + echo "****************************************" + rm tmp.$$.rs + exit 1 + fi + + # Copy over into the final destination and clean up. + "$R" --pretty normal tmp.$$.rs > $M/astencode_gen.rs + # rm -f tmp.$$.rs + exit 0 +done + +# If we made it this far, must not have found any +# serializer: +echo "serializer tool not found." diff --git a/src/etc/tidy.py b/src/etc/tidy.py index 4974bf74c5b..ca57f686dbb 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -18,8 +18,11 @@ def report_err(s): print("%s:%d: %s" % (fileinput.filename(), fileinput.filelineno(), s)) err=1 +file_names = [s for s in sys.argv[1:] if not s.endswith("_gen.rs")] + try: - for line in fileinput.input(openhook=fileinput.hook_encoded("utf-8")): + for line in fileinput.input(file_names, + openhook=fileinput.hook_encoded("utf-8")): if (line.find('\t') != -1 and fileinput.filename().find("Makefile") == -1): report_err("tab character") |
