Exemplo n.º 1
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;
}
Exemplo n.º 2
0
void VMPrimitive::EmptyRoutine(Interpreter*, VMFrame*) {
    VMSymbol* sig = GetSignature();
    Universe::ErrorPrint("undefined primitive called: " + sig->GetStdString() + "\n");
}
Exemplo n.º 3
0
void _Symbol::AsString(VMObject* /*object*/, VMFrame* frame) {
    VMSymbol* sym = static_cast<VMSymbol*>(frame->Pop());

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