本文整理汇总了C++中Interpreter::ExecuteContext方法的典型用法代码示例。如果您正苦于以下问题:C++ Interpreter::ExecuteContext方法的具体用法?C++ Interpreter::ExecuteContext怎么用?C++ Interpreter::ExecuteContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interpreter
的用法示例。
在下文中一共展示了Interpreter::ExecuteContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestSimpleBranchTrue
void TestSimpleBranchTrue()
{
Interpreter i;
Context context;
// Test the following program:
//
// while (false) {}
//
// if (false)
// {
// while (true) {}
// }
//
// This program should terminate.
int8_t instructions[] = {
Load_Constant_Short, 0,
Branch_True, -1,
Load_Constant_Short, 1,
Branch_True, 5,
Load_Constant_Short, 1,
Branch_True, -1,
Halt,
};
i.ExecuteContext(&context, instructions);
}
示例2: TestSimpleBranch
void TestSimpleBranch()
{
Interpreter i;
Context context;
// This program should terminate.
int8_t instructions[] = {
Jump, 2,
Jump, 0,
Halt,
};
i.ExecuteContext(&context, instructions);
}
示例3: TestLoadShortConstants
void TestLoadShortConstants()
{
Interpreter i;
Context context;
int8_t instructions[] = {
Load_Constant_Short, 1,
Load_Constant_Short, 2,
Halt,
};
i.ExecuteContext(&context, instructions);
Assert(context.stack.At(0).AsInteger() == 1, "stack[0] != 1");
Assert(context.stack.At(1).AsInteger() == 2, "stack[1] != 2");
}
示例4: TestSimpleAdd
void TestSimpleAdd()
{
Interpreter i;
Context context;
int8_t instructions[] = {
Load_Constant_Short, 1,
Load_Constant_Short, 2,
Add,
Halt,
};
i.ExecuteContext(&context, instructions);
Assert(context.stack.At(0).AsInteger() == 3, "stack[0] != 3");
}
示例5: TestLoadIntegerConstants
void TestLoadIntegerConstants()
{
Interpreter i;
Context context;
int8_t instructions[] = {
Load_Constant_Integer, 0x0A, 0x1B, 0x2C, 0x3D,
Load_Constant_Integer, 0x12, 0x34, 0x56, 0x78,
Halt,
};
i.ExecuteContext(&context, instructions);
Assert(context.stack.At(0).AsInteger() == 0x0A1B2C3D, "stack[0] != 0x0A1B2C3D");
Assert(context.stack.At(1).AsInteger() == 0x12345678, "stack[1] != 0x12345678");
}
示例6: TestSimpleFunction
void TestSimpleFunction()
{
Interpreter i;
Context context;
int8_t instructions[] = {
Load_Constant_Short, 1,
Load_Constant_Short, 2,
Load_Constant_Short, 3,
Call, 3,
Add,
Halt,
Load_Constant_Short, 4,
Load_Constant_Short, 5,
Return,
};
i.ExecuteContext(&context, instructions);
Assert(context.stack.At(0).AsInteger() == 1, "stack[0] != 1");
Assert(context.stack.At(1).AsInteger() == 5, "stack[0] != 5");
}