Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Vm Struct Reference

Public Member Functions

double operator() (double x) const
 

Public Attributes

CodeSet code_
 

Detailed Description

Definition at line 55 of file calc2.cpp.

Member Function Documentation

◆ operator()()

double Vm::operator() ( double x) const
inline

Definition at line 57 of file calc2.cpp.

58 {
59 const size_t maxStack = 16;
60 double stack[maxStack];
61 double *p = stack;
62 CodeSet::const_iterator pc = code_.begin();
63
64 while (pc != code_.end()) {
65 switch (pc->op_) {
66 case OpVarX:
67 *p++ = x;
68 break;
69 case OpImm:
70 *p++ = pc->val_;
71 break;
72 case OpNeg:
73 p[-1] = -p[-1];
74 break;
75 case OpAdd:
76 --p;
77 p[-1] += p[0];
78 break;
79 case OpSub:
80 --p;
81 p[-1] -= p[0];
82 break;
83 case OpMul:
84 --p;
85 p[-1] *= p[0];
86 break;
87 case OpDiv:
88 --p;
89 p[-1] /= p[0];
90 break;
91 }
92 ++pc;
93 assert(p < stack + maxStack);
94 }
95 return p[-1];
96 }
const mie::Vuint & p
Definition bn.cpp:27
@ OpVarX
Definition calc2.cpp:35
@ OpMul
Definition calc2.cpp:31
@ OpNeg
Definition calc2.cpp:33
@ OpSub
Definition calc2.cpp:30
@ OpDiv
Definition calc2.cpp:32
@ OpImm
Definition calc2.cpp:34
@ OpAdd
Definition calc2.cpp:29
CodeSet code_
Definition calc2.cpp:56

Member Data Documentation

◆ code_

CodeSet Vm::code_

Definition at line 56 of file calc2.cpp.


The documentation for this struct was generated from the following file: