本文整理汇总了C++中VMMethod::SetBytecode方法的典型用法代码示例。如果您正苦于以下问题:C++ VMMethod::SetBytecode方法的具体用法?C++ VMMethod::SetBytecode怎么用?C++ VMMethod::SetBytecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMMethod
的用法示例。
在下文中一共展示了VMMethod::SetBytecode方法的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();
}