Created
March 1, 2014 23:33
-
-
Save anonymous/9299344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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