1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 08:55:37 +00: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); n[i].compile(program, context);
} }
PUSH_INS(program, Call, context.addFunction(getName()), getName()); PUSH_INS(program, Call, context.getFunctionAddress(getName()), getName());
} }
// ReturnNode compile //////////////////////////////////////////////////////////// // ReturnNode compile ////////////////////////////////////////////////////////////
@ -631,12 +631,7 @@ void MathInterpreter::parse(void)
// interpreter ///////////////////////////////////////////////////////////////// // interpreter /////////////////////////////////////////////////////////////////
#define ADD_FUNC(context, func)\ #define ADD_FUNC(context, func)\
try\ (context).addFunction(#func, &STDMATH_NAMESPACE::func);\
{\
(context).setFunction(#func, &STDMATH_NAMESPACE::func);\
}\
catch (Exceptions::Definition)\
{}
#define ADD_STDMATH_FUNCS(context)\ #define ADD_STDMATH_FUNCS(context)\
ADD_FUNC(context, cos);\ ADD_FUNC(context, cos);\
@ -694,6 +689,8 @@ void MathInterpreter::compile(RunContext &context)
{ {
if (root_) if (root_)
{ {
context.addVariable("pi", Math::pi);
ADD_STDMATH_FUNCS(context);
root_->compile(program_, context); root_->compile(program_, context);
for (unsigned int i = 0; i < program_.size(); ++i) for (unsigned int i = 0; i < program_.size(); ++i)
{ {
@ -705,7 +702,6 @@ void MathInterpreter::compile(RunContext &context)
break; break;
} }
} }
ADD_STDMATH_FUNCS(context);
} }
if (!root_||!gotReturn) if (!root_||!gotReturn)
{ {