summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pfunction.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-07-04 09:28:49 +0200
committer couriersud <couriersud@gmx.org>2020-07-04 09:28:49 +0200
commitbdc1bb4778aaa4cbf75d6bfc7340859a9858590c (patch)
tree5f33b37124ad76e0cd1a929a9559a5baecfb275f /src/lib/netlist/plib/pfunction.cpp
parentedab7d1a40941edc9f242ce5ca6f95baeda81ad6 (diff)
netlist: fix pfunction if
The if postfix evaluation corrupted the stack.
Diffstat (limited to 'src/lib/netlist/plib/pfunction.cpp')
-rw-r--r--src/lib/netlist/plib/pfunction.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp
index f6096de6953..f977059ff69 100644
--- a/src/lib/netlist/plib/pfunction.cpp
+++ b/src/lib/netlist/plib/pfunction.cpp
@@ -295,6 +295,8 @@ namespace plib {
postfix.push_back(opstk.top());
opstk.pop();
}
+ //for (auto &e : postfix)
+ // printf("\t %s\n", e.c_str());
compile_postfix(inputs, postfix, expr);
}
@@ -320,9 +322,9 @@ namespace plib {
return narrow_cast<NT>(lfsr);
}
+ #define ST0 stack[ptr+1]
#define ST1 stack[ptr]
#define ST2 stack[ptr-1]
- #define ST3 stack[ptr-2]
#define OP(OP, ADJ, EXPR) \
case OP: \
@@ -350,7 +352,7 @@ namespace plib {
OP(LT, 1, ST2 < ST1 ? 1.0 : 0.0)
OP(LE, 1, ST2 <= ST1 ? 1.0 : 0.0)
OP(GE, 1, ST2 >= ST1 ? 1.0 : 0.0)
- OP(IF, 1, (ST3 != 0.0) ? ST2 : ST1)
+ OP(IF, 2, (ST2 != 0.0) ? ST1 : ST0)
OP(POW, 1, plib::pow(ST2, ST1))
OP(LOG, 0, plib::log(ST2))
OP(SIN, 0, plib::sin(ST2))