Exemplo n.º 1
0
 virtual void SetUp() {
     mosh_init();
     Transcoder* transcoder = createNativeTranscoder();
     const Object inPort    = Object::makeTextualInputPort(new StandardInputPort(), transcoder);
     const Object outPort   = Object::makeTextualOutputPort(new StandardOutputPort(), transcoder);
     errorPort_ = Object::makeStringOutputPort();
     theVM_ = new TestingVM(10000, outPort, errorPort_, inPort, false /* isProfiler */);
     theVM_->loadCompiler();
     theVM_->setValueString(UC("%loadpath"), Object::False);
 }
Exemplo n.º 2
0
VM* VMFactory::create(int initialStackSize, bool isProfilerOn)
{
    // At first, we shared the standard ports between VMs.
    // But it causes inconsistent buffering state on Buffered port.
    // So we never share the standard ports.

    // N.B. For debug safety, we never close() the standard ports.
    const Object inPort    = Object::makeTextualInputPort(new StandardInputPort,
                                                          File::STANDARD_IN.isUTF16Console() ? createNativeConsoleTranscoder() : createNativeTranscoder());
    const Object outPort   = Object::makeTextualOutputPort(new StandardOutputPort,
                                                           File::STANDARD_OUT.isUTF16Console() ? createNativeConsoleTranscoder() : createNativeTranscoder());
    const Object errorPort = Object::makeTextualOutputPort(new StandardErrorPort,
                                                           File::STANDARD_OUT.isUTF16Console() ? createNativeConsoleTranscoder() : createNativeTranscoder());

    VM* vm = new VM(initialStackSize, outPort, errorPort, inPort, isProfilerOn);
    vm->registerPort(outPort);
    vm->loadCompiler();
	register_stubs(vm);
    return vm;
}