mail[Wesnoth-commits] r33566 - /trunk/src/formula.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dragonking on March 12, 2009 - 09:12:
Author: dragonking
Date: Thu Mar 12 09:12:45 2009
New Revision: 33566

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33566&view=rev
Log:
Fixed formula . operator bug

Modified:
    trunk/src/formula.cpp

Modified: trunk/src/formula.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula.cpp?rev=33566&r1=33565&r2=33566&view=diff
==============================================================================
--- trunk/src/formula.cpp (original)
+++ trunk/src/formula.cpp Thu Mar 12 09:12:45 2009
@@ -194,6 +194,28 @@
        }
 };
 
+class dot_callable : public formula_callable {
+public:
+       dot_callable(const formula_callable &global,
+                       const formula_callable& local)
+               : global_(global), local_(local) { }
+private:
+       const formula_callable& global_, &local_;
+
+       void get_inputs(std::vector<formula_input>* inputs) const {
+            return local_.get_inputs(inputs);
+       }
+
+       variant get_value(const std::string& key) const {
+            variant v = local_.query_value(key);
+
+            if ( v == variant() )
+               return global_.query_value(key);
+            else
+                return v;
+       }
+};
+
 class dot_expression : public formula_expression {
 public:
        dot_expression(expression_ptr left, expression_ptr right)
@@ -204,14 +226,17 @@
                const variant left = left_->evaluate(variables);
                if(!left.is_callable()) {
                        if(left.is_list()) {
-                               return right_->evaluate(list_callable(left));
+                                list_callable list_call(left);
+                                dot_callable callable(variables, list_call);
+                               return right_->evaluate(callable);
                        }
 
                        return left;
                }
 
-               return right_->evaluate(*left.as_callable());
-       }
+                dot_callable callable(variables, *left.as_callable());
+                return right_->evaluate(callable);
+        }
 
        expression_ptr left_, right_;
 };




Related Messages


Powered by MHonArc, Updated Thu Mar 12 10:20:34 2009