Esempio n. 1
0
void CloneObjectsTest::testCloneSymbol() {
    VMSymbol* orig = GetUniverse()->NewSymbol("foobar");
    VMSymbol* clone = orig->Clone();

    CPPUNIT_ASSERT((intptr_t)orig != (intptr_t)clone);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("class differs!!", orig->GetClass(),
            clone->GetClass());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("objectSize differs!!", orig->GetObjectSize(),
            clone->GetObjectSize());
    //CPPUNIT_ASSERT_EQUAL_MESSAGE("numberOfFields differs!!", orig->numberOfFields, clone->numberOfFields);
    CPPUNIT_ASSERT_EQUAL_MESSAGE("string differs!!!", orig->GetPlainString(), clone->GetPlainString());
}
Esempio n. 2
0
VMClass* SourcecodeCompiler::CompileClass( const StdString& path,
        const StdString& file,
        VMClass* systemClass ) {
    VMClass* result = systemClass;

    StdString fname = path + fileSeparator + file + ".som";

    ifstream* fp = new ifstream();
    fp->open(fname.c_str(), std::ios_base::in);
    if (!fp->is_open()) {
        return nullptr;
    }

    if (parser != nullptr) delete(parser);
    parser = new Parser(*fp);
    result = compile(systemClass);

    VMSymbol* cname = result->GetName();
    StdString cnameC = cname->GetStdString();

    if (file != cnameC) {

        ostringstream Str;
        Str << "Filename: " << file << " does not match class name " << cnameC;

        showCompilationError(file, Str.str().c_str());
        return nullptr;
    }
    delete(parser);
    parser = nullptr;
    delete(fp);
#ifdef COMPILER_DEBUG
    Universe::ErrorPrint("Compilation finished\n");
#endif
    return result;
}
Esempio n. 3
0
void VMPrimitive::EmptyRoutine(Interpreter*, VMFrame*) {
    VMSymbol* sig = GetSignature();
    Universe::ErrorPrint("undefined primitive called: " + sig->GetStdString() + "\n");
}
Esempio n. 4
0
void _Symbol::AsString(VMObject* /*object*/, VMFrame* frame) {
    VMSymbol* sym = static_cast<VMSymbol*>(frame->Pop());

    StdString str = sym->GetStdString();
    frame->Push(GetUniverse()->NewString(str));
}