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


C++ VMMethod::SetNumberOfLocals方法代码示例

本文整理汇总了C++中VMMethod::SetNumberOfLocals方法的典型用法代码示例。如果您正苦于以下问题:C++ VMMethod::SetNumberOfLocals方法的具体用法?C++ VMMethod::SetNumberOfLocals怎么用?C++ VMMethod::SetNumberOfLocals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VMMethod的用法示例。


在下文中一共展示了VMMethod::SetNumberOfLocals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initialize

void Universe::initialize(long _argc, char** _argv) {
#ifdef GENERATE_ALLOCATION_STATISTICS
    allocationStats["VMArray"] = {0,0};
#endif

    heapSize = 1 * 1024 * 1024;

    vector<StdString> argv = handleArguments(_argc, _argv);
    
    // remember file that was executed (for writing statistics)
    if (argv.size() > 0)
        bm_name = argv[0];

    Heap<HEAP_CLS>::InitializeHeap(heapSize);

    interpreter = new Interpreter();

#if CACHE_INTEGER
# warning is _store_ptr sufficient/correct here?
    // create prebuilt integers
    for (long it = INT_CACHE_MIN_VALUE; it <= INT_CACHE_MAX_VALUE; ++it) {
        prebuildInts[(unsigned long)(it - INT_CACHE_MIN_VALUE)] = _store_ptr(new (GetHeap<HEAP_CLS>()) VMInteger(it));
    }
#endif

    InitializeGlobals();

    VMObject* systemObject = NewInstance(load_ptr(systemClass));

    SetGlobal(SymbolForChars("nil"),    load_ptr(nilObject));
    SetGlobal(SymbolForChars("true"),   load_ptr(trueObject));
    SetGlobal(SymbolForChars("false"),  load_ptr(falseObject));
    SetGlobal(SymbolForChars("system"), systemObject);
    SetGlobal(SymbolForChars("System"), load_ptr(systemClass));
    SetGlobal(SymbolForChars("Block"),  load_ptr(blockClass));

    symbolIfTrue  = _store_ptr(SymbolForChars("ifTrue:"));
    symbolIfFalse = _store_ptr(SymbolForChars("ifFalse:"));

    

    VMMethod* bootstrapMethod = NewMethod(SymbolForChars("bootstrap"), 1, 0);
    bootstrapMethod->SetBytecode(0, BC_HALT);
    bootstrapMethod->SetNumberOfLocals(0);

    bootstrapMethod->SetMaximumNumberOfStackElements(2);
    bootstrapMethod->SetHolder(load_ptr(systemClass));

    if (argv.size() == 0) {
        Shell* shell = new Shell(bootstrapMethod);
        shell->Start();
        return;
    }

    /* only trace bootstrap if the number of cmd-line "-d"s is > 2 */
    short trace = 2 - dumpBytecodes;
    if (!(trace > 0))
        dumpBytecodes = 1;

    VMArray* argumentsArray = NewArrayFromStrings(argv);

    VMFrame* bootstrapFrame = interpreter->PushNewFrame(bootstrapMethod);
    bootstrapFrame->Push(systemObject);
    bootstrapFrame->Push(argumentsArray);

    VMInvokable* initialize = load_ptr(systemClass)->LookupInvokable(
                                            SymbolForChars("initialize:"));
    (*initialize)(bootstrapFrame);

    // reset "-d" indicator
    if (!(trace > 0))
        dumpBytecodes = 2 - trace;

    interpreter->Start();
}
开发者ID:jdegeete,项目名称:SOMpp,代码行数:75,代码来源:Universe.cpp


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