summaryrefslogtreecommitdiff
path: root/cpp/src/FreezeScript/Parser.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-11-14 09:56:46 -0800
committerMark Spruiell <mes@zeroc.com>2007-11-14 09:56:46 -0800
commit39f02759cb59efea1ebea37c41ab991e5bd71f6c (patch)
treef6e8775dd80c9c63bf75264b8a0e8812eda43b35 /cpp/src/FreezeScript/Parser.cpp
parentBut 2534. (diff)
downloadice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.tar.bz2
ice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.tar.xz
ice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.zip
- Fixing NullHandleException in FreezeScript when a script attempts to
access the 'length' member of a string value. - Adding support for string concatenation using the '+' operator. - Updating the FreezeScript/dbmap test to include string functions.
Diffstat (limited to 'cpp/src/FreezeScript/Parser.cpp')
-rw-r--r--cpp/src/FreezeScript/Parser.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/cpp/src/FreezeScript/Parser.cpp b/cpp/src/FreezeScript/Parser.cpp
index ca3c2bdcb9c..0ef4287a0b0 100644
--- a/cpp/src/FreezeScript/Parser.cpp
+++ b/cpp/src/FreezeScript/Parser.cpp
@@ -275,9 +275,22 @@ FreezeScript::BinaryNode::evaluate(const SymbolTablePtr& st)
{
DataPtr leftValue = _left->evaluate(st);
DataPtr rightValue = _right->evaluate(st);
+ StringDataPtr sleft = StringDataPtr::dynamicCast(leftValue);
+ StringDataPtr sright = StringDataPtr::dynamicCast(rightValue);
IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue);
IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue);
- if(ileft && iright)
+ if(sleft || sright)
+ {
+ if(sleft && sright)
+ {
+ result = _factory->createString(leftValue->stringValue() + rightValue->stringValue(), true);
+ }
+ else
+ {
+ _factory->getErrorReporter()->error("string concatenation requires two string arguments");
+ }
+ }
+ else if(ileft && iright)
{
result = _factory->createInteger(leftValue->integerValue() + rightValue->integerValue(), true);
}