本文整理汇总了C++中Interpreter类的典型用法代码示例。如果您正苦于以下问题:C++ Interpreter类的具体用法?C++ Interpreter怎么用?C++ Interpreter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interpreter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleInvoke
void Debugger::handleInvoke(Interpreter interpreter, const Arabica::DOM::Element<std::string>& invokeElem, const std::string& invokeId, Breakpoint::When when, Breakpoint::Action action) {
if (!interpreter.isRunning())
return;
boost::shared_ptr<DebugSession> session = getSession(interpreter);
if (!session)
return;
Breakpoint breakpointTemplate;
breakpointTemplate.when = when;
breakpointTemplate.action = action;
std::list<Breakpoint> qualifiedBreakpoints = getQualifiedInvokeBreakpoints(interpreter, invokeElem, invokeId, breakpointTemplate);
session->checkBreakpoints(qualifiedBreakpoints);
}
示例2: main
int main()
{
Interpreter inter;
inter.statement_analyzer ("var s=4;");
inter.statement_analyzer ("var g=5-2*s;");
inter.statement_analyzer ("print g;");
inter.statement_analyzer ("print \"\n\";");
inter.statement_analyzer ("pause;");
}
示例3: inkamath_test
void inkamath_test()
{
Interpreter<complex<double>> p;
queue<string> s;
s.push("[pi, e]");
s.push("A=[a a; a a]");
s.push("a=[1 2;3 4]");
s.push("A");
s.push("exp(x)_n=exp(x)_(n-1)+x^n/!n");
s.push("exp(1)");
s.push("cos(x)=(exp(i*x)+exp(-i*x))/2");
s.push("sin(x)=(exp(i*x)-exp(-i*x))/(2*i)");
s.push("sin(pi/6)");
while(!s.empty())
{
cout << ">> " << s.front() << endl;
if(s.front()=="q") break; // quit interpreter
cout << p.Eval(s.front()) << endl << endl;
s.pop();
}
}
示例4: canHandleOpcodes
bool canHandleOpcodes(CodeBlock* codeBlock)
{
Interpreter* interpreter = codeBlock->globalData()->interpreter;
Instruction* instructionsBegin = codeBlock->instructions().begin();
unsigned instructionCount = codeBlock->instructions().size();
for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount; ) {
switch (interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode)) {
#define DEFINE_OP(opcode, length) \
case opcode: \
if (!canHandleOpcode(opcode)) \
return false; \
bytecodeOffset += length; \
break;
FOR_EACH_OPCODE_ID(DEFINE_OP)
#undef DEFINE_OP
default:
ASSERT_NOT_REACHED();
break;
}
}
return true;
}
示例5: computePreciseJumpTargets
void computePreciseJumpTargets(CodeBlock* codeBlock, Vector<unsigned, 32>& out)
{
ASSERT(out.isEmpty());
// We will derive a superset of the jump targets that the code block thinks it has.
// So, if the code block claims there are none, then we are done.
if (!codeBlock->numberOfJumpTargets())
return;
for (unsigned i = codeBlock->numberOfExceptionHandlers(); i--;)
out.append(codeBlock->exceptionHandler(i).target);
Interpreter* interpreter = codeBlock->vm()->interpreter;
Instruction* instructionsBegin = codeBlock->instructions().begin();
unsigned instructionCount = codeBlock->instructions().size();
for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) {
OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode);
getJumpTargetsForBytecodeOffset(codeBlock, interpreter, instructionsBegin, bytecodeOffset, out);
bytecodeOffset += opcodeLengths[opcodeID];
}
std::sort(out.begin(), out.end());
// We will have duplicates, and we must remove them.
unsigned toIndex = 0;
unsigned fromIndex = 0;
unsigned lastValue = UINT_MAX;
while (fromIndex < out.size()) {
unsigned value = out[fromIndex++];
if (value == lastValue)
continue;
out[toIndex++] = value;
lastValue = value;
}
out.resize(toIndex);
}
示例6: main
int main() {
plan(8);
Interpreter universe;
String value = universe.value_of("test");
ok(value, "value");
is(value, "test", "value == \"test\"");
isnt(value, "tset", "value != \"tset\"");
is(value, std::string("test"), "value = std::string(\"test\")");
is(value.length(), 4u, "length(value) == 4");
note("value.replace(2, 2, value)");
value.replace(2, 2, value);
is(value, "tetest", "value = \"tetest\"");
note("value.insert(2, \"st\")");
value.insert(2, "st");
is(value, "testtest", "value == \"testest\"");
note("value = \"test\"");
value = "test";
is(value, "test", "value == \"test\"");
return exit_status();
}
示例7: handleInvoke
void Debugger::handleInvoke(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeId, Breakpoint::When when, Breakpoint::Action action) {
InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
if (!session->_isRunning)
return;
Breakpoint breakpointTemplate;
breakpointTemplate.when = when;
breakpointTemplate.action = action;
std::list<Breakpoint> qualifiedBreakpoints = getQualifiedInvokeBreakpoints(impl, invokeElem, invokeId, breakpointTemplate);
session->checkBreakpoints(qualifiedBreakpoints);
}
示例8: catch
void PostponeElement::Resubmitter::onStableConfiguration(Interpreter interpreter) {
std::list<Postponed>::iterator eventIter = _postponedEvents.begin();
bool dispatched = false;
while(eventIter != _postponedEvents.end()) {
try {
// LOG(INFO) << "Reevaluating: >> " << eventIter->first << " <<";
if ((!dispatched || eventIter->chaining) && interpreter.getDataModel().evalAsBool(eventIter->until)) {
// LOG(INFO) << " -> is TRUE";
eventIter->event.name += ".postponed";
interpreter.receive(eventIter->event, true);
_postponedEvents.erase(eventIter++);
dispatched = true;
}
// LOG(INFO) << " -> is FALSE";
} catch (Event e) {
LOG(ERROR) << "Syntax error while evaluating until attribute of postpone element:" << std::endl << e << std::endl;
_postponedEvents.erase(eventIter++);
continue;
}
eventIter++;
}
// LOG(ERROR) << _postponedEvents.size() << " Postponess remaining";
}
示例9: main
int main(void){
vector<int>b;
set<int> a;
b.push_back(1);
b.push_back(2);
b.push_back(1);
b.push_back(2);
a.insert(b.begin(), b.end());
Interpreter interpreter;
//AUXInsertInto* newwww = static_cast<AUXInsertInto*>(neww);
API api;
fstream fp;
//fp.open("/Users/jason/Desktop/file", ios::in|ios::binary);
//freopen("/Users/jason/Desktop/file", "r", stdin);
while (true) {
cout<<">>";
AUX* neww = interpreter.dealInput();
if(neww->quit)
return 0;
api.chooseCommand(neww);
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl;
}
cout<<"haha";
}
示例10: handleMicrostep
void Debugger::handleMicrostep(Interpreter interpreter, Breakpoint::When when) {
if (!interpreter.isRunning())
return;
boost::shared_ptr<DebugSession> session = getSession(interpreter);
if (!session)
return;
std::list<Breakpoint> breakpoints;
Breakpoint breakpoint;
breakpoint.when = when;
breakpoint.subject = Breakpoint::MICROSTEP;
breakpoints.push_back(breakpoint);
session->checkBreakpoints(breakpoints);
}
示例11: handleMicrostep
void Debugger::handleMicrostep(Interpreter& interpreter, Breakpoint::When when) {
InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
if (!session->_isRunning)
return;
std::list<Breakpoint> breakpoints;
Breakpoint breakpoint;
breakpoint.when = when;
breakpoint.subject = Breakpoint::MICROSTEP;
breakpoints.push_back(breakpoint);
session->checkBreakpoints(breakpoints);
}
示例12: getQualifiedInvokeBreakpoints
std::list<Breakpoint> getQualifiedInvokeBreakpoints(Interpreter interpreter, const Arabica::DOM::Element<std::string>& invokeElem, const std::string invokeId, Breakpoint breakpointTemplate) {
std::list<Breakpoint> breakpoints;
Breakpoint bp = breakpointTemplate; // copy base as template
bp.subject = Breakpoint::INVOKER;
bp.element = invokeElem;
bp.invokeId = invokeId;
if (HAS_ATTR(invokeElem, "type")) {
bp.invokeType = ATTR(invokeElem, "type");
} else if (HAS_ATTR(invokeElem, "typeexpr")) {
bp.invokeType = interpreter.getDataModel().evalAsString(ATTR(invokeElem, "typeexpr"));
}
breakpoints.push_back(bp);
return breakpoints;
}
示例13: handleEvent
void Debugger::handleEvent(Interpreter interpreter, const Event& event, Breakpoint::When when) {
if (!interpreter.isRunning())
return;
boost::shared_ptr<DebugSession> session = getSession(interpreter);
if (!session)
return;
std::list<Breakpoint> breakpoints;
Breakpoint breakpoint;
breakpoint.when = when;
breakpoint.eventName = event.name;
breakpoint.subject = Breakpoint::EVENT;
breakpoints.push_back(breakpoint);
session->checkBreakpoints(breakpoints);
}
示例14: handleEvent
void Debugger::handleEvent(Interpreter& interpreter, const Event& event, Breakpoint::When when) {
InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
if (!session->_isRunning)
return;
std::list<Breakpoint> breakpoints;
Breakpoint breakpoint;
breakpoint.when = when;
breakpoint.eventName = event.name;
breakpoint.subject = Breakpoint::EVENT;
breakpoints.push_back(breakpoint);
session->checkBreakpoints(breakpoints);
}
示例15: handleExecutable
void Debugger::handleExecutable(Interpreter& interpreter,
const XERCESC_NS::DOMElement* execContentElem,
Breakpoint::When when) {
std::shared_ptr<DebugSession> session = getSession(interpreter.getImpl().get());
if (!session)
return;
if (!session->_isRunning)
return;
std::list<Breakpoint> breakpoints;
Breakpoint breakpoint;
breakpoint.when = when;
breakpoint.element = execContentElem;
breakpoint.executableName = X(execContentElem->getLocalName()).str();
breakpoint.subject = Breakpoint::EXECUTABLE;
breakpoints.push_back(breakpoint);
session->checkBreakpoints(breakpoints);
}