Commit adffb038 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function expr_run_type_fun().

parent e770e64d
......@@ -1881,6 +1881,104 @@ expr_run_type_var(nodeType *p, parseParamType *parse_arg)
return p;
}
nodeType *
expr_run_type_fun1c(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
const auto funcID = get_funcID(p->u.fun1c.name);
const auto functype = fun_sym_tbl[funcID].type;
nodeType *rnode = nullptr;
if (functype == FT_1C)
{
auto fnode = expr_run(p->u.fun1c.op, parse_arg);
const auto value = p->u.fun1c.value;
rnode = fun1c(init, funcID, fnode, value, parse_arg);
}
else
{
cdoAbort("Syntax error in call to %s(), check number of parameter!\n", p->u.fun1c.name);
}
return rnode;
}
nodeType *
expr_run_type_fun2c(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
const auto funcID = get_funcID(p->u.fun2c.name);
const auto functype = fun_sym_tbl[funcID].type;
nodeType *rnode = nullptr;
if (functype == FT_2C)
{
auto fnode = expr_run(p->u.fun2c.op, parse_arg);
const auto value1 = p->u.fun2c.value1;
const auto value2 = p->u.fun2c.value2;
rnode = fun2c(init, funcID, fnode, value1, value2, parse_arg);
}
else
{
cdoAbort("Syntax error in call to %s(), check number of parameter!\n", p->u.fun1c.name);
}
return rnode;
}
nodeType *
expr_run_type_fun(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
nodeType *rnode = nullptr;
const auto funcID = get_funcID(p->u.fun.name);
auto functype = fun_sym_tbl[funcID].type;
auto fnode = expr_run(p->u.fun.op, parse_arg);
if (functype == FT_COORD)
{
rnode = coord_fun(init, funcID, fnode, parse_arg);
}
else if (functype == FT_0)
{
const auto vartsID = parse_arg->tsID;
rnode = ex_fun0_con(init, funcID, params[vartsID].data);
}
else
{
functype = fun_sym_tbl[funcID].type;
const auto funcflag = fun_sym_tbl[funcID].flag;
if (functype == FT_FLD && funcflag == 1)
{
const auto coordID = params_get_coordID(parse_arg, 'w', fnode->param.gridID);
if (init)
parse_arg->coords[coordID].needed = true;
else
fnode->param.weight = parse_arg->coords[coordID].data.data();
}
rnode = ex_fun(init, funcID, fnode);
// if ( fnode->ltmpobj ) node_delete(fnode);
// Free(fnode);
}
return rnode;
}
/*
nodeType *
expr_run_type_(nodeType *p, parseParamType *parse_arg)
{
const auto init = parse_arg->init;
auto params = parse_arg->params;
}
*/
nodeType *
expr_run(nodeType *p, parseParamType *parse_arg)
{
......@@ -1915,74 +2013,17 @@ expr_run(nodeType *p, parseParamType *parse_arg)
}
case typeFun1c:
{
const auto funcID = get_funcID(p->u.fun1c.name);
const auto functype = fun_sym_tbl[funcID].type;
if (functype == FT_1C)
{
auto fnode = expr_run(p->u.fun1c.op, parse_arg);
const auto value = p->u.fun1c.value;
rnode = fun1c(init, funcID, fnode, value, parse_arg);
}
else
{
cdoAbort("Syntax error in call to %s(), check number of parameter!\n", p->u.fun1c.name);
}
rnode = expr_run_type_fun1c(p, parse_arg);
break;
}
case typeFun2c:
{
const auto funcID = get_funcID(p->u.fun2c.name);
const auto functype = fun_sym_tbl[funcID].type;
if (functype == FT_2C)
{
auto fnode = expr_run(p->u.fun2c.op, parse_arg);
const auto value1 = p->u.fun2c.value1;
const auto value2 = p->u.fun2c.value2;
rnode = fun2c(init, funcID, fnode, value1, value2, parse_arg);
}
else
{
cdoAbort("Syntax error in call to %s(), check number of parameter!\n", p->u.fun1c.name);
}
rnode = expr_run_type_fun2c(p, parse_arg);
break;
}
case typeFun:
{
const auto funcID = get_funcID(p->u.fun.name);
auto functype = fun_sym_tbl[funcID].type;
auto fnode = expr_run(p->u.fun.op, parse_arg);
if (functype == FT_COORD)
{
rnode = coord_fun(init, funcID, fnode, parse_arg);
}
else if (functype == FT_0)
{
const auto vartsID = parse_arg->tsID;
rnode = ex_fun0_con(init, funcID, params[vartsID].data);
}
else
{
functype = fun_sym_tbl[funcID].type;
const auto funcflag = fun_sym_tbl[funcID].flag;
if (functype == FT_FLD && funcflag == 1)
{
const auto coordID = params_get_coordID(parse_arg, 'w', fnode->param.gridID);
if (init)
parse_arg->coords[coordID].needed = true;
else
fnode->param.weight = parse_arg->coords[coordID].data.data();
}
rnode = ex_fun(init, funcID, fnode);
// if ( fnode->ltmpobj ) node_delete(fnode);
// Free(fnode);
}
rnode = expr_run_type_fun(p, parse_arg);
break;
}
case typeOpr:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment