From f934135efc44575d9205d8f0875e5b5f09a815a3 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 19 Jul 2013 10:56:27 -0400 Subject: [PATCH] nitg: add option --global Signed-off-by: Jean Privat --- benchmarks/bench_engines.sh | 26 +++++++++++++------------- benchmarks/bench_languages.sh | 2 +- src/nitg.nit | 5 +++++ tests/nitg.args | 4 ++-- tests/sav/nitg.res | 1 + tests/tests.sh | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/benchmarks/bench_engines.sh b/benchmarks/bench_engines.sh index 5ec8a00..c2ee85f 100755 --- a/benchmarks/bench_engines.sh +++ b/benchmarks/bench_engines.sh @@ -113,7 +113,7 @@ function run_compiler() shift if test -n "$fast"; then run_command "$@" ../src/nitg.nit -o "nitg.$title.bin" - bench_command "nitg" "nitg ../src/test_parser.nit" "./nitg.$title.bin" -v --no-cc ../src/test_parser.nit + bench_command "nitg" "nitg --global ../src/test_parser.nit" "./nitg.$title.bin" -v --global --no-cc ../src/test_parser.nit run_command "$@" ../src/nit.nit -o "nit.$title.bin" bench_command "nit" "nit ../src/test_parser.nit ../src/location.nit" "./nit.$title.bin" -v ../src/test_parser.nit -- -n ../src/location.nit run_command "$@" ../examples/shoot/shoot_logic.nit -o "shoot.$title.bin" @@ -122,7 +122,7 @@ function run_compiler() bench_command "bintrees" "bench_bintree_gen 16" "./bintrees.$title.bin" 16 else run_command "$@" ../src/nitg.nit -o "nitg.$title.bin" - bench_command "nitg" "nitg --no-cc ../src/nitmetrics.nit" "./nitg.$title.bin" -v --no-cc ../src/nitmetrics.nit + bench_command "nitg" "nitg --global --no-cc ../src/nitmetrics.nit" "./nitg.$title.bin" -v --global --no-cc ../src/nitmetrics.nit bench_command "nitg-s" "nitg --separate ../src/nitg.nit" "./nitg.$title.bin" -v --no-cc --separate ../src/nitg.nit run_command "$@" ../src/nit.nit -o "nit.$title.bin" bench_command "nit" "nit ../src/test_parser.nit ../src/rapid_type_analysis.nit" "./nit.$title.bin" -v ../src/test_parser.nit -- -n ../src/rapid_type_analysis.nit @@ -206,11 +206,11 @@ function bench_steps() bench_command "generate c" "" ../src/nitc_3 --global --no-cc ../src/nitg.nit bench_command "full" "" ../src/nitc_3 -O --global ../src/nitg.nit -o "nitg_nitc-g.bin" - prepare_res "$name-nitg.dat" "nitg" "Various steps of nitg" - bench_command "parse" "" ./nitg --only-parse ../src/nitg.nit - bench_command "metamodel" "" ./nitg --only-metamodel ../src/nitg.nit - bench_command "generate c" "" ./nitg --no-cc ../src/nitg.nit - bench_command "full" "" ./nitg ../src/nitg.nit -o "nitg_nitg.bin" + prepare_res "$name-nitg.dat" "nitg" "Various steps of nitg --global" + bench_command "parse" "" ./nitg --global --only-parse ../src/nitg.nit + bench_command "metamodel" "" ./nitg --global --only-metamodel ../src/nitg.nit + bench_command "generate c" "" ./nitg --global --no-cc ../src/nitg.nit + bench_command "full" "" ./nitg --global ../src/nitg.nit -o "nitg_nitg.bin" prepare_res "$name-nitg-e.dat" "nitg-e" "Various steps of nitg --erasure" bench_command "parse" "" ./nitg --erasure --only-parse ../src/nitg.nit @@ -230,16 +230,16 @@ function bench_nitg_options() name="$FUNCNAME-$tag" skip_test "$name" && return prepare_res "$name.dat" "no options" "nitg without options" - run_compiler "nitg" ./nitg + run_compiler "nitg" ./nitg --global if test -n "$2"; then prepare_res "$name-all.dat" "all" "nitg with all options $@" - run_compiler "nitg-$tag" ./nitg $@ + run_compiler "nitg-$tag" ./nitg --global $@ fi for opt in "$@"; do prepare_res "$name$opt.dat" "$opt" "nitg with option $opt" - run_compiler "nitg$opt" ./nitg $opt + run_compiler "nitg$opt" ./nitg --global $opt done plot "$name.gnu" @@ -334,8 +334,8 @@ function bench_engines() run_compiler "nitc" ../src/nitc_3 -O prepare_res "$name-nitc-g.dat" "nitc-g" "nitc with --global" run_compiler "nitc-g" ../src/nitc_3 -O --global - prepare_res "$name-nitg.dat" "nitg" "nitg" - run_compiler "nitg" ./nitg + prepare_res "$name-nitg.dat" "nitg" "nitg with --global" + run_compiler "nitg" ./nitg --global prepare_res "$name-nitg-s.dat" "nitg-s" "nitg with --separate" run_compiler "nitg-s" ./nitg --separate prepare_res "$name-nitg-e.dat" "nitg-e" "nitg with --erasure" @@ -418,7 +418,7 @@ function bench_compilation_time done prepare_res "$name-nitg.dat" "nitg" "nitg" for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitg.nit; do - bench_command `basename "$i" .nit` "" ./nitg "$i" --no-cc + bench_command `basename "$i" .nit` "" ./nitg --global "$i" --no-cc done prepare_res "$name-nitg-e.dat" "nitg-e" "nitg --erasure" for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitg.nit; do diff --git a/benchmarks/bench_languages.sh b/benchmarks/bench_languages.sh index 28720d7..5348c8d 100755 --- a/benchmarks/bench_languages.sh +++ b/benchmarks/bench_languages.sh @@ -221,7 +221,7 @@ function bench_language() nitdir="${basedir}/nit" prepare_res $nitdir/$name-nitg.dat "nitg" "nitg" for b in $seq; do - run_command ./nitg $nitdir/${t}_$b.nit -o "$nitdir/${t}_$b.nitg.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" + run_command ./nitg $nitdir/${t}_$b.nit --global -o "$nitdir/${t}_$b.nitg.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\"" bench_command "$b" "" "$nitdir/${t}_$b.nitg.bin" $s done diff --git a/src/nitg.nit b/src/nitg.nit index 58872b0..7b442a0 100644 --- a/src/nitg.nit +++ b/src/nitg.nit @@ -26,6 +26,11 @@ import separate_compiler # Create a tool context to handle options and paths var toolcontext = new ToolContext + +# Create a new option for --global +var opt_global = new OptionBool("Use global compilation", "--global") +toolcontext.option_context.add_option(opt_global) + # We do not add other options, so process them now! toolcontext.process_options diff --git a/tests/nitg.args b/tests/nitg.args index 58ee17a..1f1e8d5 100644 --- a/tests/nitg.args +++ b/tests/nitg.args @@ -1,4 +1,4 @@ -../examples/hello_world.nit -o out/nitg-hello_world ; out/nitg-hello_world -base_simple3.nit -o out/nitg-base_simple3 ; out/nitg-base_simple3 +--global ../examples/hello_world.nit -o out/nitg-hello_world ; out/nitg-hello_world +--global base_simple3.nit -o out/nitg-base_simple3 ; out/nitg-base_simple3 --separate ../examples/hello_world.nit -o out/nitgs-hello_world ; out/nitgs-hello_world --separate base_simple3.nit -o out/nitgs-base_simple3 ; out/nitgs-base_simple3 diff --git a/tests/sav/nitg.res b/tests/sav/nitg.res index 45959cb..5f5c45f 100644 --- a/tests/sav/nitg.res +++ b/tests/sav/nitg.res @@ -32,3 +32,4 @@ --tables-metrics Enable static size measuring of tables used for vft, typing and resolution --erasure Erase generic types --no-check-erasure-cast Disable implicit casts on unsafe return with erasure-typing policy (dangerous) + --global Use global compilation diff --git a/tests/tests.sh b/tests/tests.sh index c5a3a98..f470498 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -229,7 +229,7 @@ done enginebinname=$engine case $engine in nitc) ;; - nitg) ;; + nitg) OPT="--global $OPT";; nitg-s) enginebinname=nitg; OPT="--separate $OPT";; nitg-e) enginebinname=nitg; OPT="--erasure $OPT";; nit) engine=niti ;; -- 1.7.9.5