]> gitweb.hamatoma.de Git - reqt/commitdiff
dayly work
authorhama <hama@siduction.net>
Sun, 7 Sep 2014 22:14:05 +0000 (00:14 +0200)
committerhama <hama@siduction.net>
Sun, 7 Sep 2014 22:14:05 +0000 (00:14 +0200)
rplexpr/rplastree.cpp

index 30eb2adcb26f3e37ba649733055992e0103c6e16..de8e3e57d81626785ebfcee0f0c36be8203fc804 100644 (file)
@@ -53,6 +53,9 @@ enum {
     LOC_ITEM_AS_INT_1,
     LOC_ITEM_AS_INT_2,
     LOC_METHOD_CALL_CHECK_1,
+    LOC_MEHTOD_CALL_CHECK_2,
+    LOC_MEHTOD_CALL_CHECK_3,    // 11035
+    LOC_MEHTOD_CALL_CHECK_4,
     LOC_COUNT
 };
 
@@ -2977,18 +2980,40 @@ bool RplASMethodCall::check(RplParser& parser)
     RplASExprStatement* args = dynamic_cast<RplASExprStatement*>(m_child2);
     int argCount = 0;
     RplASMethod* method = m_method;
-    RplASExprStatement* params = dynamic_cast<RplASExprStatement*>(method->child2());
+    RplASVarDefinition* params = dynamic_cast<RplASVarDefinition*>(method->child2());
     while (args != NULL && params != NULL){
         argCount++;
-        RplASCalculable* argExpr = dynamic_cast<RplASCalculable*>(args->child2());
+        RplASCalculable* argExpr = dynamic_cast<RplASCalculable*>
+                (args->child2());
         if (argExpr == NULL)
             rc = error(LOC_METHOD_CALL_CHECK_1, parser,
                        "argument %d misses expr", argCount);
         else {
+            RplASNamedValue* var;
+            RplASItem* param = params->child2();
+            if (param == NULL
+                    || (var = dynamic_cast<RplASNamedValue*>(param)) == NULL)
+                rc = error(LOC_MEHTOD_CALL_CHECK_2, parser,
+                    "parameter %d misses named value: %s", argCount,
+                    param == NULL ? "<null>" : param->nameOfItemType());
+            else {
+                // tryConversion() calls args->args->child2()->check()!
+                RplASConversion* converter = RplASConversion::tryConversion(
+                            var->clazz(), args->child2(), parser, rc);
+                if (rc && converter != NULL)
+                    args->setChild2(converter);
 
+            }
         }
+        args = dynamic_cast<RplASExprStatement*>(args->child());
+        params = dynamic_cast<RplASVarDefinition*>(params->child());
     }
-
+    if (args != NULL && params == NULL)
+        rc = error(LOC_MEHTOD_CALL_CHECK_3, parser,
+            "too many arguments: %d are enough", argCount);
+    else if (args == NULL && params != NULL && params->child3() != NULL)
+        rc = error(LOC_MEHTOD_CALL_CHECK_4, parser,
+            "too few arguments: %d are not enough", argCount);
     return rc;
 }