Work on SourceDB:rebuild
This commit is contained in:
@@ -67,21 +67,15 @@ World::World(WorldType wt) {
|
||||
// Create the globaldb in the registry.
|
||||
LS.rawset(LuaRegistry, "globaldb", LuaNewTable);
|
||||
|
||||
// Initialize the SourceDB. At this stage, the sourcedb is
|
||||
// empty, so it's just populating the lua builtins.
|
||||
// Initialize the SourceDB.
|
||||
source_db_.init(state());
|
||||
eng::string srcerrs = source_db_.rebuild();
|
||||
|
||||
|
||||
// Clear the clock.
|
||||
clock_ = 0;
|
||||
|
||||
// Initialize global variable state.
|
||||
assign_seqno_ = 1;
|
||||
|
||||
// There shouldn't be any lua errors in the sourceDB at this
|
||||
// point, since there's no lua code in the sourceDB.
|
||||
assert(srcerrs == "");
|
||||
|
||||
LS.result();
|
||||
assert (stack_is_clear());
|
||||
}
|
||||
@@ -372,12 +366,31 @@ void World::update_source(const util::LuaSourcePtr &source) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is called from World::update_source, and also
|
||||
// from World::patch_source in the difference transmitter.
|
||||
//
|
||||
// For the moment, errors are channeled to util::dprint,
|
||||
// and 'print' statements just go to std::cerr. Neither
|
||||
// of these is ideal. We need to get serious about setting
|
||||
// up error handling.
|
||||
//
|
||||
// We also need to figure out a solution for what happens if
|
||||
// some lua source file tries to modify, say, tangible state
|
||||
// in top-level code.
|
||||
//
|
||||
void World::rebuild_sourcedb() {
|
||||
for (const eng::string &mod: source_db_.modules()) {
|
||||
eng::string err = source_db_.rebuild_module(mod);
|
||||
if (!err.empty()) {
|
||||
util::dprint(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void World::update_source(const util::LuaSourceVec &source) {
|
||||
assert(stack_is_clear());
|
||||
source_db_.update(source);
|
||||
assert(stack_is_clear());
|
||||
eng::string errs = source_db_.rebuild();
|
||||
util::dprint(errs);
|
||||
rebuild_sourcedb();
|
||||
assert(stack_is_clear());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user