1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 05:25:37 +01:00

MathInterpreter: include pi as a constant, fix in function call

This commit is contained in:
Antonin Portelli 2015-09-28 18:18:13 +01:00 committed by Antonin Portelli
parent ccce7b11c0
commit 918e1c7ce8

View File

@ -543,7 +543,7 @@ void FuncNode::compile(Program &program, RunContext &context) const
{
n[i].compile(program, context);
}
PUSH_INS(program, Call, context.addFunction(getName()), getName());
PUSH_INS(program, Call, context.getFunctionAddress(getName()), getName());
}
// ReturnNode compile ////////////////////////////////////////////////////////////
@ -631,12 +631,7 @@ void MathInterpreter::parse(void)
// interpreter /////////////////////////////////////////////////////////////////
#define ADD_FUNC(context, func)\
try\
{\
(context).setFunction(#func, &STDMATH_NAMESPACE::func);\
}\
catch (Exceptions::Definition)\
{}
(context).addFunction(#func, &STDMATH_NAMESPACE::func);\
#define ADD_STDMATH_FUNCS(context)\
ADD_FUNC(context, cos);\
@ -694,6 +689,8 @@ void MathInterpreter::compile(RunContext &context)
{
if (root_)
{
context.addVariable("pi", Math::pi);
ADD_STDMATH_FUNCS(context);
root_->compile(program_, context);
for (unsigned int i = 0; i < program_.size(); ++i)
{
@ -705,7 +702,6 @@ void MathInterpreter::compile(RunContext &context)
break;
}
}
ADD_STDMATH_FUNCS(context);
}
if (!root_||!gotReturn)
{