当前位置: 首页>>代码示例>>C++>>正文


C++ Interpreter::ExecuteContext方法代码示例

本文整理汇总了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);
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:30,代码来源:interpreter.cpp

示例2: TestSimpleBranch

void TestSimpleBranch()
{
    Interpreter i;
    Context context;

    // This program should terminate.
    int8_t instructions[] = {
        Jump, 2,
        Jump, 0,
        Halt,
    };

    i.ExecuteContext(&context, instructions);
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:14,代码来源:interpreter.cpp

示例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");
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:16,代码来源:interpreter.cpp

示例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");
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:16,代码来源:interpreter.cpp

示例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");
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:16,代码来源:interpreter.cpp

示例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");
}
开发者ID:loic-sharma,项目名称:Interpreter,代码行数:23,代码来源:interpreter.cpp


注:本文中的Interpreter::ExecuteContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。