diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-14 17:32:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-12-14 17:32:14 +0200 |
commit | af83df9be50a9383d0c54fb24b8e486a658a2a02 (patch) | |
tree | 5d937c9015c6438a60122743c7fb72ec30de32be /xsd/cxx/tree/tree-inline.cxx | |
parent | c12b36470adb57100f1d5f22e3ddd6fc163f6ab4 (diff) |
New default/fixed value initialization code
Now the default/fixed values are parsed by the compiler at compile time
instead of the standard parsing code at runtime.
Diffstat (limited to 'xsd/cxx/tree/tree-inline.cxx')
-rw-r--r-- | xsd/cxx/tree/tree-inline.cxx | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/xsd/cxx/tree/tree-inline.cxx b/xsd/cxx/tree/tree-inline.cxx index 148369f..19f9cd3 100644 --- a/xsd/cxx/tree/tree-inline.cxx +++ b/xsd/cxx/tree/tree-inline.cxx @@ -3,11 +3,12 @@ // copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <cxx/tree/tree-inline.hxx> - #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> +#include <cxx/tree/tree-inline.hxx> +#include <cxx/tree/default-value.hxx> + namespace CXX { namespace Tree @@ -422,7 +423,7 @@ namespace CXX struct Member: Traversal::Member, Context { Member (Context& c, String const& scope) - : Context (c), scope_ (scope) + : Context (c), scope_ (scope), lit_value_ (c) { } @@ -611,19 +612,32 @@ namespace CXX if (simple) { - os << inl - << "const " << scope_ << "::" << etype (m) << "& " << - scope_ << "::" << endl + String lit (lit_value_.dispatch (m.type (), m.value ())); + + os << inl; + + if (lit) + os << scope_ << "::" << etype (m) << " "; + else + os << "const " << scope_ << "::" << etype (m) << "& "; + + os << scope_ << "::" << endl << edefault_value (m) << " ()" - << "{" - << "return " << edefault_value_member (m) << ";" - << "}"; + << "{"; + + if (lit) + os << "return " << etype (m) << " (" << lit << ");"; + else + os << "return " << edefault_value_member (m) << ";"; + + os << "}"; } } } private: String scope_; + LiteralValue lit_value_; }; struct Any: Traversal::Any, |