From bd69b1b5eeaf464e85be0b6782781da6ed31fa7c Mon Sep 17 00:00:00 2001 From: hama Date: Mon, 8 Sep 2014 00:14:05 +0200 Subject: [PATCH] dayly work --- rplexpr/rplastree.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/rplexpr/rplastree.cpp b/rplexpr/rplastree.cpp index 30eb2ad..de8e3e5 100644 --- a/rplexpr/rplastree.cpp +++ b/rplexpr/rplastree.cpp @@ -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(m_child2); int argCount = 0; RplASMethod* method = m_method; - RplASExprStatement* params = dynamic_cast(method->child2()); + RplASVarDefinition* params = dynamic_cast(method->child2()); while (args != NULL && params != NULL){ argCount++; - RplASCalculable* argExpr = dynamic_cast(args->child2()); + RplASCalculable* argExpr = dynamic_cast + (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(param)) == NULL) + rc = error(LOC_MEHTOD_CALL_CHECK_2, parser, + "parameter %d misses named value: %s", argCount, + param == 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(args->child()); + params = dynamic_cast(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; } -- 2.39.5