From d0e87f35498abfaf00e570401eb99229cf9ccd3b Mon Sep 17 00:00:00 2001 From: rylek Date: Thu, 1 Oct 2009 09:07:34 +0000 Subject: [PATCH] Fixed recursion bug in expression calculator git-svn-id: svn://ultimatepp.org/upp/trunk@1596 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/TCore/CalcNode.cpp | 3 +++ uppsrc/TCore/CalcNode.h | 8 ++++++++ uppsrc/TCore/CalcType.cpp | 19 +++++++++---------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/uppsrc/TCore/CalcNode.cpp b/uppsrc/TCore/CalcNode.cpp index 42fd30b70..3a23211f4 100644 --- a/uppsrc/TCore/CalcNode.cpp +++ b/uppsrc/TCore/CalcNode.cpp @@ -10,6 +10,9 @@ NAMESPACE_UPP String CalcType::Describe() { return "lambda-výraz"; } RegisterStdCalcTypeName(const CalcNode *) +String CalcType::Describe() { return t_("lambda-expression"); } +RegisterStdCalcTypeName(CalcNodePtr) + int CharFilterCalcIdent(int c) { return IsIdent(c) ? c : 0; } int CharFilterCalcUpperIdent(int c) { return IsIdent(c) ? ToUpper(c) : 0; } diff --git a/uppsrc/TCore/CalcNode.h b/uppsrc/TCore/CalcNode.h index 02139d4dc..340bce639 100644 --- a/uppsrc/TCore/CalcNode.h +++ b/uppsrc/TCore/CalcNode.h @@ -395,6 +395,14 @@ struct CalcType : public CalcRawType static String Describe(); }; +template <> +struct CalcType : public CalcRawType +{ + static Value ToValue(CalcNodePtr cn) { return !!cn ? RawToValue(cn) : Value(); } + static CalcNodePtr ValueTo(Value v) { return IsTypeRaw(v) ? UPP::ValueTo(v) : NULL; } + static String Describe(); +}; + class CalcParser { public: diff --git a/uppsrc/TCore/CalcType.cpp b/uppsrc/TCore/CalcType.cpp index 68312cd34..f141ede56 100644 --- a/uppsrc/TCore/CalcType.cpp +++ b/uppsrc/TCore/CalcType.cpp @@ -3,16 +3,16 @@ NAMESPACE_UPP -String CalcTypeDescribeInt() { return t_("integer"); } +String CalcTypeDescribeInt() { return t_("integer"); } -String CalcType::Describe() { return t_("real number"); } -String CalcType::Describe() { return t_("string"); } -String CalcType::Describe() { return t_("date"); } -String CalcType