Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2014 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9299344 to your computer and use it in GitHub Desktop.
Save anonymous/9299344 to your computer and use it in GitHub Desktop.
class Module {
map<string, Code> exports;
// string = exported function name
// Code = actual code
list<Processes> processes;
// list of processes spawned using this module
}
class ModulePair {
Module old_module; // the old code, if any
Module new_module; // the current code
}
class Runtime {
map<string, ModulePair> mps;
// string = name of Module
// ModulePair = old + new module
}
Runtime myRuntime;
void compile(string module_name, string code) {
// kill all the the processes that are 3 generations old
list<Processes> zombies = myRuntime.mps[module_name].old_module.processes;
for(proc in zombiles) kill proc;
// replace the old module's code
myRuntime.mps[module_name].old_module = myRuntime.mps[module_name].new_module;
// link in the new module's new code
myRuntime.mps[module_name].new_module = ...(code)
}
// anytime we lookup something of the form
// foo:bar()
// we always look at the latest copy of foo
void lookup(string module_name, string func_name) {
return myRuntime.mps[module_name].new_module.exports[func_name]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment