1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-08-02 22:37:07 +01:00

math compiler supports function calls + standard C math library wrapper

This commit is contained in:
2014-01-30 19:28:30 +00:00
parent fa5ca7273c
commit 36bc0bc9b0
11 changed files with 426 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
#include <iostream>
#include <latan/Function.hpp>
#include <latan/MathCompiler.hpp>
using namespace std;
@@ -8,15 +9,21 @@ int main(int argc, char* argv[])
{
MathCompiler C(argv[1]);
VarTable vtable;
FunctionTable ftable;
stack<double> dstack;
const VirtualProgram& P = C();
ftable["exp"] = &StdMath::exp;
ftable["atan2"] = &StdMath::atan2;
cout << P << endl;
for (int i=0;i<P.size();++i)
for (unsigned int i=0;i<P.size();++i)
{
(*(P[i]))(dstack,vtable);
(*(P[i]))(dstack,vtable,ftable);
}
if (!dstack.empty())
{
cout << "result= " << dstack.top() << endl;
}
cout << "result= " << dstack.top() << endl;
return EXIT_SUCCESS;
}