diff options
author | Morgan Deters <mdeters@cs.nyu.edu> | 2013-04-23 23:03:37 -0400 |
---|---|---|
committer | Morgan Deters <mdeters@cs.nyu.edu> | 2013-04-23 23:16:58 -0400 |
commit | b25991f4c2779c34b51cd51b943290a4a3d2a9fd (patch) | |
tree | aaec41cf29cc3574288c6110ba246f361d84ec3a /src/theory/mktheorytraits | |
parent | a006e7b92327668b76a1ab993007f42fe91052c3 (diff) |
Theory "alternates" support
* This is a feature that Dejan and I want for the upcoming tutorial.
It allows rapid prototyping of new decision procedure implementations
(which we may choose to demonstrate), and a new --use-theory command-line
option to select from different available implementations. It has no
affect on the current set of theories, as no "alternates" are defined.
* Also update the new-theory script, which was broken and incomplete.
Diffstat (limited to 'src/theory/mktheorytraits')
-rwxr-xr-x | src/theory/mktheorytraits | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/theory/mktheorytraits b/src/theory/mktheorytraits index 3edc7c140..97ede32d5 100755 --- a/src/theory/mktheorytraits +++ b/src/theory/mktheorytraits @@ -40,6 +40,7 @@ template=$1; shift theory_traits= theory_includes= +theory_constructors= theory_for_each_macro="#define CVC4_FOR_EACH_THEORY \\ " @@ -72,13 +73,13 @@ seen_theory=false seen_theory_builtin=false function theory { - # theory T header + # theory ID T header lineno=${BASH_LINENO[0]} if $seen_theory; then - echo "$kf:$lineno: theory declaration can only appear once" >&2 - exit 1; + echo "$kf:$lineno: error: multiple theories defined in one file !?" >&2 + exit 1 fi # this script doesn't care about the theory class information, but @@ -109,6 +110,30 @@ function theory { " } +function alternate { + # alternate ID name T header + + lineno=${BASH_LINENO[0]} + + if $seen_theory; then + echo "$kf:$lineno: error: multiple theories defined in one file !?" >&2 + exit 1 + fi + + seen_theory=true + seen_endtheory=true + + theory_header="$4" + theory_includes="${theory_includes}#include \"$theory_header\" +" + + eval "alternate_for_$1=\"\${alternate_for_$1} + if(options::theoryAlternates()[\\\"$2\\\"]) { + engine->addTheory< $3 >($1); + return; + }\"" +} + function rewriter { # rewriter class header lineno=${BASH_LINENO[0]} @@ -128,10 +153,17 @@ function endtheory { seen_endtheory=true + theory_constructors="${theory_constructors} + case $theory_id: +\$alternate_for_$theory_id + engine->addTheory< $theory_class >($theory_id); + return; +" + theory_traits="${theory_traits} template<> struct TheoryTraits<${theory_id}> { - typedef ${theory_class} theory_class; + // typedef ${theory_class} theory_class; typedef ${rewriter_class} rewriter_class; static const bool isStableInfinite = ${theory_stable_infinite}; @@ -368,6 +400,8 @@ check_builtin_theory_seen ## output +eval "theory_constructors=\"$theory_constructors\"" + # generate warnings about incorrect #line annotations in templates nl -ba -s' ' "$template" | grep '^ *[0-9][0-9]* # *line' | awk '{OFS="";if($1+1!=$3) print "'"$template"':",$1,": warning: incorrect annotation \"#line ",$3,"\" (it should be \"#line ",($1+1),"\")"}' >&2 @@ -377,6 +411,7 @@ for var in \ theory_traits \ theory_for_each_macro \ theory_includes \ + theory_constructors \ template \ type_enumerator_includes \ mk_type_enumerator_type_constant_cases \ |