add runtime warnings for stale files
This commit is contained in:
@@ -48,6 +48,41 @@ if (use_mcode) {
|
||||
mcode_mod = boot_load("mcode", boot_env)
|
||||
}
|
||||
|
||||
// Warn if any .cm source is newer than its .mach bytecode
|
||||
function check_mach_stale() {
|
||||
var pairs = [
|
||||
["tokenize.cm", "tokenize.mach"],
|
||||
["parse.cm", "parse.mach"],
|
||||
["fold.cm", "fold.mach"],
|
||||
["mcode.cm", "mcode.mach"],
|
||||
["internal/bootstrap.cm", "internal/bootstrap.mach"],
|
||||
["internal/engine.cm", "internal/engine.mach"]
|
||||
]
|
||||
var stale = []
|
||||
var _i = 0
|
||||
var cm_path = null
|
||||
var mach_path = null
|
||||
var cm_stat = null
|
||||
var mach_stat = null
|
||||
while (_i < length(pairs)) {
|
||||
cm_path = core_path + '/' + pairs[_i][0]
|
||||
mach_path = core_path + '/' + pairs[_i][1]
|
||||
if (fd.is_file(cm_path) && fd.is_file(mach_path)) {
|
||||
cm_stat = fd.stat(cm_path)
|
||||
mach_stat = fd.stat(mach_path)
|
||||
if (cm_stat.mtime > mach_stat.mtime) {
|
||||
push(stale, pairs[_i][0])
|
||||
}
|
||||
}
|
||||
_i = _i + 1
|
||||
}
|
||||
if (length(stale) > 0) {
|
||||
print("warning: bytecode is stale for: " + text(stale, ", ") + "\n")
|
||||
print("run 'make regen' or './cell --core . regen.cm' to update\n")
|
||||
}
|
||||
}
|
||||
check_mach_stale()
|
||||
|
||||
// analyze: tokenize + parse, check for errors
|
||||
function analyze(src, filename) {
|
||||
var tok_result = tokenize_mod(src, filename)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user