rm array proto funcs
This commit is contained in:
26
bench.ce
26
bench.ce
@@ -186,7 +186,7 @@ function collect_benches(package_name, specific_bench) {
|
|||||||
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
|
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
|
||||||
if (bench_name != match_base) return
|
if (bench_name != match_base) return
|
||||||
}
|
}
|
||||||
bench_files.push(f)
|
push(bench_files, f)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return bench_files
|
return bench_files
|
||||||
@@ -348,7 +348,7 @@ function run_single_bench(bench_fn, bench_name) {
|
|||||||
if (teardown_fn) teardown_fn(state)
|
if (teardown_fn) teardown_fn(state)
|
||||||
|
|
||||||
var ns_per_op = is_batch ? duration / batch_size : duration
|
var ns_per_op = is_batch ? duration / batch_size : duration
|
||||||
timings_per_op.push(ns_per_op)
|
push(timings_per_op, ns_per_op)
|
||||||
} else {
|
} else {
|
||||||
var start = os.now()
|
var start = os.now()
|
||||||
if (is_batch) {
|
if (is_batch) {
|
||||||
@@ -359,7 +359,7 @@ function run_single_bench(bench_fn, bench_name) {
|
|||||||
var duration = os.now() - start
|
var duration = os.now() - start
|
||||||
|
|
||||||
var ns_per_op = is_batch ? duration / batch_size : duration
|
var ns_per_op = is_batch ? duration / batch_size : duration
|
||||||
timings_per_op.push(ns_per_op)
|
push(timings_per_op, ns_per_op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,11 +439,11 @@ function run_benchmarks(package_name, specific_bench) {
|
|||||||
|
|
||||||
var benches = []
|
var benches = []
|
||||||
if (is_function(bench_mod)) {
|
if (is_function(bench_mod)) {
|
||||||
benches.push({name: 'main', fn: bench_mod})
|
push(benches, {name: 'main', fn: bench_mod})
|
||||||
} else if (is_object(bench_mod)) {
|
} else if (is_object(bench_mod)) {
|
||||||
arrfor(array(bench_mod), function(k) {
|
arrfor(array(bench_mod), function(k) {
|
||||||
if (is_function(bench_mod[k]))
|
if (is_function(bench_mod[k]))
|
||||||
benches.push({name: k, fn: bench_mod[k]})
|
push(benches, {name: k, fn: bench_mod[k]})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ function run_benchmarks(package_name, specific_bench) {
|
|||||||
try {
|
try {
|
||||||
var result = run_single_bench(b.fn, b.name)
|
var result = run_single_bench(b.fn, b.name)
|
||||||
result.package = pkg_result.package
|
result.package = pkg_result.package
|
||||||
file_result.benchmarks.push(result)
|
push(file_result.benchmarks, result)
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
|
|
||||||
log.console(` ${result.name}`)
|
log.console(` ${result.name}`)
|
||||||
@@ -470,7 +470,7 @@ function run_benchmarks(package_name, specific_bench) {
|
|||||||
name: b.name,
|
name: b.name,
|
||||||
error: e.toString()
|
error: e.toString()
|
||||||
}
|
}
|
||||||
file_result.benchmarks.push(error_result)
|
push(file_result.benchmarks, error_result)
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -482,12 +482,12 @@ function run_benchmarks(package_name, specific_bench) {
|
|||||||
name: "load_module",
|
name: "load_module",
|
||||||
error: `Error loading module: ${e}`
|
error: `Error loading module: ${e}`
|
||||||
}
|
}
|
||||||
file_result.benchmarks.push(error_result)
|
push(file_result.benchmarks, error_result)
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length(file_result.benchmarks) > 0) {
|
if (length(file_result.benchmarks) > 0) {
|
||||||
pkg_result.files.push(file_result)
|
push(pkg_result.files, file_result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,15 +499,15 @@ var all_results = []
|
|||||||
|
|
||||||
if (all_pkgs) {
|
if (all_pkgs) {
|
||||||
if (testlib.is_valid_package('.')) {
|
if (testlib.is_valid_package('.')) {
|
||||||
all_results.push(run_benchmarks(null, null))
|
push(all_results, run_benchmarks(null, null))
|
||||||
}
|
}
|
||||||
|
|
||||||
var packages = shop.list_packages()
|
var packages = shop.list_packages()
|
||||||
arrfor(packages, function(pkg) {
|
arrfor(packages, function(pkg) {
|
||||||
all_results.push(run_benchmarks(pkg, null))
|
push(all_results, run_benchmarks(pkg, null))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
all_results.push(run_benchmarks(target_pkg, target_bench))
|
push(all_results, run_benchmarks(target_pkg, target_bench))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate totals
|
// Calculate totals
|
||||||
@@ -579,7 +579,7 @@ Total benchmarks: ${total_benches}
|
|||||||
var pkg_benches = []
|
var pkg_benches = []
|
||||||
arrfor(pkg_res.files, function(f) {
|
arrfor(pkg_res.files, function(f) {
|
||||||
arrfor(f.benchmarks, function(benchmark) {
|
arrfor(f.benchmarks, function(benchmark) {
|
||||||
pkg_benches.push(benchmark)
|
push(pkg_benches, benchmark)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ function make_shapes(n) {
|
|||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var o = { a: i }
|
var o = { a: i }
|
||||||
o[`p${i}`] = i
|
o[`p${i}`] = i
|
||||||
out.push(o)
|
push(out, o)
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_packed_array(n) {
|
function make_packed_array(n) {
|
||||||
var a = []
|
var a = []
|
||||||
for (var i = 0; i < n; i++) a.push(i)
|
for (var i = 0; i < n; i++) push(a, i)
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ return {
|
|||||||
var x = 0
|
var x = 0
|
||||||
for (var j = 0; j < n; j++) {
|
for (var j = 0; j < n; j++) {
|
||||||
var a = []
|
var a = []
|
||||||
for (var i = 0; i < 256; i++) a.push(i)
|
for (var i = 0; i < 256; i++) push(a, i)
|
||||||
x = (x + length(a)) | 0
|
x = (x + length(a)) | 0
|
||||||
}
|
}
|
||||||
return blackhole(sink, x)
|
return blackhole(sink, x)
|
||||||
|
|||||||
@@ -109,12 +109,12 @@ function benchArrayOps() {
|
|||||||
var pushTime = measureTime(function() {
|
var pushTime = measureTime(function() {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
for (var i = 0; i < iterations.medium; i++) {
|
for (var i = 0; i < iterations.medium; i++) {
|
||||||
arr.push(i);
|
push(arr, i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var arr = [];
|
var arr = [];
|
||||||
for (var i = 0; i < 10000; i++) arr.push(i);
|
for (var i = 0; i < 10000; i++) push(arr, i);
|
||||||
|
|
||||||
var accessTime = measureTime(function() {
|
var accessTime = measureTime(function() {
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
@@ -198,7 +198,7 @@ function benchStringOps() {
|
|||||||
|
|
||||||
var strings = [];
|
var strings = [];
|
||||||
for (var i = 0; i < 1000; i++) {
|
for (var i = 0; i < 1000; i++) {
|
||||||
strings.push("string" + i);
|
push(strings, "string" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var joinTime = measureTime(function() {
|
var joinTime = measureTime(function() {
|
||||||
@@ -269,13 +269,13 @@ function benchClosures() {
|
|||||||
var closureCreateTime = measureTime(function() {
|
var closureCreateTime = measureTime(function() {
|
||||||
var funcs = [];
|
var funcs = [];
|
||||||
for (var i = 0; i < iterations.medium; i++) {
|
for (var i = 0; i < iterations.medium; i++) {
|
||||||
funcs.push(makeAdder(i));
|
push(funcs, makeAdder(i));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var adders = [];
|
var adders = [];
|
||||||
for (var i = 0; i < 1000; i++) {
|
for (var i = 0; i < 1000; i++) {
|
||||||
adders.push(makeAdder(i));
|
push(adders, makeAdder(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
var closureCallTime = measureTime(function() {
|
var closureCallTime = measureTime(function() {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var newarr = []
|
|||||||
var accstr = ""
|
var accstr = ""
|
||||||
for (var i = 0; i < 10000; i++) {
|
for (var i = 0; i < 10000; i++) {
|
||||||
accstr += i;
|
accstr += i;
|
||||||
newarr.push(i.toString())
|
newarrpush(i.toString())
|
||||||
}
|
}
|
||||||
// Arrays to store timing results
|
// Arrays to store timing results
|
||||||
var jsonDecodeTimes = [];
|
var jsonDecodeTimes = [];
|
||||||
@@ -23,22 +23,22 @@ for (var i = 0; i < 100; i++) {
|
|||||||
// JSON Decode test
|
// JSON Decode test
|
||||||
var start = os.now();
|
var start = os.now();
|
||||||
var jll = json.decode(ll);
|
var jll = json.decode(ll);
|
||||||
jsonDecodeTimes.push((os.now() - start) * 1000);
|
jsonDecodeTimespush((os.now() - start) * 1000);
|
||||||
|
|
||||||
// JSON Encode test
|
// JSON Encode test
|
||||||
start = os.now();
|
start = os.now();
|
||||||
var jsonStr = JSON.stringify(jll);
|
var jsonStr = JSON.stringify(jll);
|
||||||
jsonEncodeTimes.push((os.now() - start) * 1000);
|
jsonEncodeTimespush((os.now() - start) * 1000);
|
||||||
|
|
||||||
// NOTA Encode test
|
// NOTA Encode test
|
||||||
start = os.now();
|
start = os.now();
|
||||||
var nll = nota.encode(jll);
|
var nll = nota.encode(jll);
|
||||||
notaEncodeTimes.push((os.now() - start) * 1000);
|
notaEncodeTimespush((os.now() - start) * 1000);
|
||||||
|
|
||||||
// NOTA Decode test
|
// NOTA Decode test
|
||||||
start = os.now();
|
start = os.now();
|
||||||
var oll = nota.decode(nll);
|
var oll = nota.decode(nll);
|
||||||
notaDecodeTimes.push((os.now() - start) * 1000);
|
notaDecodeTimespush((os.now() - start) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate statistics
|
// Calculate statistics
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ function runBenchmarkForLibrary(lib, bench) {
|
|||||||
// store only in the very first iteration, so we can decode them later
|
// store only in the very first iteration, so we can decode them later
|
||||||
// but do not store them every iteration or we blow up memory.
|
// but do not store them every iteration or we blow up memory.
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
encodedList.push(e);
|
push(encodedList, e);
|
||||||
totalSize += lib.getSize(e);
|
totalSize += lib.getSize(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
82
build.cm
82
build.cm
@@ -35,7 +35,7 @@ function replace_sigils(str) {
|
|||||||
function replace_sigils_array(flags) {
|
function replace_sigils_array(flags) {
|
||||||
var result = []
|
var result = []
|
||||||
arrfor(flags, function(flag) {
|
arrfor(flags, function(flag) {
|
||||||
result.push(replace_sigils(flag))
|
resultpush(replace_sigils(flag))
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -121,30 +121,30 @@ Build.compile_file = function(pkg, file, target, buildtype = 'release') {
|
|||||||
|
|
||||||
// Add buildtype-specific flags
|
// Add buildtype-specific flags
|
||||||
if (buildtype == 'release') {
|
if (buildtype == 'release') {
|
||||||
cmd_parts.push('-O3', '-DNDEBUG')
|
cmd_partspush('-O3', '-DNDEBUG')
|
||||||
} else if (buildtype == 'debug') {
|
} else if (buildtype == 'debug') {
|
||||||
cmd_parts.push('-O2', '-g')
|
cmd_partspush('-O2', '-g')
|
||||||
} else if (buildtype == 'minsize') {
|
} else if (buildtype == 'minsize') {
|
||||||
cmd_parts.push('-Os', '-DNDEBUG')
|
cmd_partspush('-Os', '-DNDEBUG')
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_parts.push('-DCELL_USE_NAME=' + sym_name)
|
cmd_partspush('-DCELL_USE_NAME=' + sym_name)
|
||||||
cmd_parts.push('-I"' + pkg_dir + '"')
|
cmd_partspush('-I"' + pkg_dir + '"')
|
||||||
|
|
||||||
// Add package CFLAGS (resolve relative -I paths)
|
// Add package CFLAGS (resolve relative -I paths)
|
||||||
arrfor(cflags, function(flag) {
|
arrfor(cflags, function(flag) {
|
||||||
if (starts_with(flag, '-I') && !starts_with(flag, '-I/')) {
|
if (starts_with(flag, '-I') && !starts_with(flag, '-I/')) {
|
||||||
flag = '-I"' + pkg_dir + '/' + text(flag, 2) + '"'
|
flag = '-I"' + pkg_dir + '/' + text(flag, 2) + '"'
|
||||||
}
|
}
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add target CFLAGS
|
// Add target CFLAGS
|
||||||
arrfor(target_cflags, function(flag) {
|
arrfor(target_cflags, function(flag) {
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd_parts.push('"' + src_path + '"')
|
cmd_partspush('"' + src_path + '"')
|
||||||
|
|
||||||
var cmd_str = text(cmd_parts, ' ')
|
var cmd_str = text(cmd_parts, ' ')
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ Build.build_package = function(pkg, target = Build.detect_host_target(), exclude
|
|||||||
|
|
||||||
arrfor(c_files, function(file) {
|
arrfor(c_files, function(file) {
|
||||||
var obj = Build.compile_file(pkg, file, target, buildtype)
|
var obj = Build.compile_file(pkg, file, target, buildtype)
|
||||||
objects.push(obj)
|
objectspush(obj)
|
||||||
})
|
})
|
||||||
|
|
||||||
return objects
|
return objects
|
||||||
@@ -198,17 +198,17 @@ function compute_link_key(objects, ldflags, target_ldflags, target, cc) {
|
|||||||
|
|
||||||
// Build a string representing all link inputs
|
// Build a string representing all link inputs
|
||||||
var parts = []
|
var parts = []
|
||||||
parts.push('target:' + target)
|
partspush('target:' + target)
|
||||||
parts.push('cc:' + cc)
|
partspush('cc:' + cc)
|
||||||
arrfor(sorted_objects, function(obj) {
|
arrfor(sorted_objects, function(obj) {
|
||||||
// Object paths are content-addressed, so the path itself is the hash
|
// Object paths are content-addressed, so the path itself is the hash
|
||||||
parts.push('obj:' + obj)
|
partspush('obj:' + obj)
|
||||||
})
|
})
|
||||||
arrfor(ldflags, function(flag) {
|
arrfor(ldflags, function(flag) {
|
||||||
parts.push('ldflag:' + flag)
|
partspush('ldflag:' + flag)
|
||||||
})
|
})
|
||||||
arrfor(target_ldflags, function(flag) {
|
arrfor(target_ldflags, function(flag) {
|
||||||
parts.push('target_ldflag:' + flag)
|
partspush('target_ldflag:' + flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
return content_hash(text(parts, '\n'))
|
return content_hash(text(parts, '\n'))
|
||||||
@@ -249,7 +249,7 @@ Build.build_dynamic = function(pkg, target = Build.detect_host_target(), buildty
|
|||||||
if (starts_with(flag, '-L') && !starts_with(flag, '-L/')) {
|
if (starts_with(flag, '-L') && !starts_with(flag, '-L/')) {
|
||||||
flag = '-L"' + pkg_dir + '/' + text(flag, 2) + '"'
|
flag = '-L"' + pkg_dir + '/' + text(flag, 2) + '"'
|
||||||
}
|
}
|
||||||
resolved_ldflags.push(flag)
|
resolved_ldflagspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Compute link key
|
// Compute link key
|
||||||
@@ -279,46 +279,46 @@ Build.build_dynamic = function(pkg, target = Build.detect_host_target(), buildty
|
|||||||
// Platform-specific flags for undefined symbols (resolved at dlopen) and size optimization
|
// Platform-specific flags for undefined symbols (resolved at dlopen) and size optimization
|
||||||
if (tc.system == 'darwin') {
|
if (tc.system == 'darwin') {
|
||||||
// Allow undefined symbols - they will be resolved when dlopen'd into the main executable
|
// Allow undefined symbols - they will be resolved when dlopen'd into the main executable
|
||||||
cmd_parts.push('-undefined', 'dynamic_lookup')
|
cmd_partspush('-undefined', 'dynamic_lookup')
|
||||||
// Dead-strip unused code
|
// Dead-strip unused code
|
||||||
cmd_parts.push('-Wl,-dead_strip')
|
cmd_partspush('-Wl,-dead_strip')
|
||||||
// Set install_name to stable path so runtime finds it correctly
|
// Set install_name to stable path so runtime finds it correctly
|
||||||
cmd_parts.push('-Wl,-install_name,' + stable_path)
|
cmd_partspush('-Wl,-install_name,' + stable_path)
|
||||||
// rpath for .cell/local libraries
|
// rpath for .cell/local libraries
|
||||||
cmd_parts.push('-Wl,-rpath,@loader_path/../local')
|
cmd_partspush('-Wl,-rpath,@loader_path/../local')
|
||||||
cmd_parts.push('-Wl,-rpath,' + local_dir)
|
cmd_partspush('-Wl,-rpath,' + local_dir)
|
||||||
} else if (tc.system == 'linux') {
|
} else if (tc.system == 'linux') {
|
||||||
// Allow undefined symbols at link time
|
// Allow undefined symbols at link time
|
||||||
cmd_parts.push('-Wl,--allow-shlib-undefined')
|
cmd_partspush('-Wl,--allow-shlib-undefined')
|
||||||
// Garbage collect unused sections
|
// Garbage collect unused sections
|
||||||
cmd_parts.push('-Wl,--gc-sections')
|
cmd_partspush('-Wl,--gc-sections')
|
||||||
// rpath for .cell/local libraries
|
// rpath for .cell/local libraries
|
||||||
cmd_parts.push('-Wl,-rpath,$ORIGIN/../local')
|
cmd_partspush('-Wl,-rpath,$ORIGIN/../local')
|
||||||
cmd_parts.push('-Wl,-rpath,' + local_dir)
|
cmd_partspush('-Wl,-rpath,' + local_dir)
|
||||||
} else if (tc.system == 'windows') {
|
} else if (tc.system == 'windows') {
|
||||||
// Windows DLLs: use --allow-shlib-undefined for mingw
|
// Windows DLLs: use --allow-shlib-undefined for mingw
|
||||||
cmd_parts.push('-Wl,--allow-shlib-undefined')
|
cmd_partspush('-Wl,--allow-shlib-undefined')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add .cell/local to library search path
|
// Add .cell/local to library search path
|
||||||
cmd_parts.push('-L"' + local_dir + '"')
|
cmd_partspush('-L"' + local_dir + '"')
|
||||||
|
|
||||||
arrfor(objects, function(obj) {
|
arrfor(objects, function(obj) {
|
||||||
cmd_parts.push('"' + obj + '"')
|
cmd_partspush('"' + obj + '"')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Do NOT link against core library - symbols resolved at dlopen time
|
// Do NOT link against core library - symbols resolved at dlopen time
|
||||||
|
|
||||||
// Add LDFLAGS
|
// Add LDFLAGS
|
||||||
arrfor(resolved_ldflags, function(flag) {
|
arrfor(resolved_ldflags, function(flag) {
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
arrfor(target_ldflags, function(flag) {
|
arrfor(target_ldflags, function(flag) {
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd_parts.push('-o', '"' + store_path + '"')
|
cmd_partspush('-o', '"' + store_path + '"')
|
||||||
|
|
||||||
var cmd_str = text(cmd_parts, ' ')
|
var cmd_str = text(cmd_parts, ' ')
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ Build.build_static = function(packages, target = Build.detect_host_target(), out
|
|||||||
var objects = Build.build_package(pkg, target, !is_core, buildtype)
|
var objects = Build.build_package(pkg, target, !is_core, buildtype)
|
||||||
|
|
||||||
arrfor(objects, function(obj) {
|
arrfor(objects, function(obj) {
|
||||||
all_objects.push(obj)
|
all_objectspush(obj)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Collect LDFLAGS (with sigil replacement)
|
// Collect LDFLAGS (with sigil replacement)
|
||||||
@@ -375,7 +375,7 @@ Build.build_static = function(packages, target = Build.detect_host_target(), out
|
|||||||
if (starts_with(flag, '-L') && !starts_with(flag, '-L/')) {
|
if (starts_with(flag, '-L') && !starts_with(flag, '-L/')) {
|
||||||
flag = '-L"' + pkg_dir + '/' + text(flag, 2) + '"'
|
flag = '-L"' + pkg_dir + '/' + text(flag, 2) + '"'
|
||||||
}
|
}
|
||||||
all_ldflags.push(flag)
|
all_ldflagspush(flag)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -396,18 +396,18 @@ Build.build_static = function(packages, target = Build.detect_host_target(), out
|
|||||||
var cmd_parts = [cc]
|
var cmd_parts = [cc]
|
||||||
|
|
||||||
arrfor(all_objects, function(obj) {
|
arrfor(all_objects, function(obj) {
|
||||||
cmd_parts.push('"' + obj + '"')
|
cmd_partspush('"' + obj + '"')
|
||||||
})
|
})
|
||||||
|
|
||||||
arrfor(all_ldflags, function(flag) {
|
arrfor(all_ldflags, function(flag) {
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
arrfor(target_ldflags, function(flag) {
|
arrfor(target_ldflags, function(flag) {
|
||||||
cmd_parts.push(flag)
|
cmd_partspush(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd_parts.push('-o', '"' + output + '"')
|
cmd_partspush('-o', '"' + output + '"')
|
||||||
|
|
||||||
var cmd_str = text(cmd_parts, ' ')
|
var cmd_str = text(cmd_parts, ' ')
|
||||||
|
|
||||||
@@ -436,10 +436,10 @@ Build.build_all_dynamic = function(target, buildtype = 'release') {
|
|||||||
if (find(packages, 'core') != null) {
|
if (find(packages, 'core') != null) {
|
||||||
try {
|
try {
|
||||||
var lib = Build.build_dynamic('core', target, buildtype)
|
var lib = Build.build_dynamic('core', target, buildtype)
|
||||||
results.push({ package: 'core', library: lib })
|
resultspush({ package: 'core', library: lib })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('Failed to build core: ' + text(e))
|
log.error('Failed to build core: ' + text(e))
|
||||||
results.push({ package: 'core', error: e })
|
resultspush({ package: 'core', error: e })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,11 +449,11 @@ Build.build_all_dynamic = function(target, buildtype = 'release') {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
var lib = Build.build_dynamic(pkg, target, buildtype)
|
var lib = Build.build_dynamic(pkg, target, buildtype)
|
||||||
results.push({ package: pkg, library: lib })
|
resultspush({ package: pkg, library: lib })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('Failed to build ' + pkg + ': ')
|
log.error('Failed to build ' + pkg + ': ')
|
||||||
log.error(e)
|
log.error(e)
|
||||||
results.push({ package: pkg, error: e })
|
resultspush({ package: pkg, error: e })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
20
cellfs.cm
20
cellfs.cm
@@ -169,18 +169,14 @@ function mount(source, name) {
|
|||||||
throw Error("Unsupported mount source type: " + source)
|
throw Error("Unsupported mount source type: " + source)
|
||||||
}
|
}
|
||||||
|
|
||||||
mounts.push(mount_info)
|
push(mounts, mount_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmount
|
// Unmount
|
||||||
function unmount(name_or_source) {
|
function unmount(name_or_source) {
|
||||||
for (var i = 0; i < length(mounts); i++) {
|
mounts = filter(mounts, function(mount) {
|
||||||
if (mounts[i].name == name_or_source || mounts[i].source == name_or_source) {
|
return mount.name != name_or_source && mount.source != name_or_source
|
||||||
mounts.splice(i, 1)
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw Error("Mount not found: " + name_or_source)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
@@ -322,7 +318,7 @@ function enumerate(path, recurse) {
|
|||||||
|
|
||||||
arrfor(list, function(item) {
|
arrfor(list, function(item) {
|
||||||
var item_rel = rel_prefix ? rel_prefix + "/" + item : item
|
var item_rel = rel_prefix ? rel_prefix + "/" + item : item
|
||||||
results.push(item_rel)
|
push(results, item_rel)
|
||||||
|
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
var st = fd.stat(fd.join_paths(curr_full, item))
|
var st = fd.stat(fd.join_paths(curr_full, item))
|
||||||
@@ -361,7 +357,7 @@ function enumerate(path, recurse) {
|
|||||||
|
|
||||||
if (!seen[rel]) {
|
if (!seen[rel]) {
|
||||||
seen[rel] = true
|
seen[rel] = true
|
||||||
results.push(rel)
|
push(results, rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -415,7 +411,7 @@ function globfs(globs, dir) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!check_neg(item_rel) && check_pos(item_rel)) {
|
if (!check_neg(item_rel) && check_pos(item_rel)) {
|
||||||
results.push(item_rel)
|
push(results, item_rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -438,7 +434,7 @@ function globfs(globs, dir) {
|
|||||||
if (length(rel) == 0) return
|
if (length(rel) == 0) return
|
||||||
|
|
||||||
if (!check_neg(rel) && check_pos(rel)) {
|
if (!check_neg(rel) && check_pos(rel)) {
|
||||||
results.push(rel)
|
push(results, rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
18
clean.ce
18
clean.ce
@@ -94,13 +94,13 @@ if (is_shop_scope) {
|
|||||||
packages_to_clean = shop.list_packages()
|
packages_to_clean = shop.list_packages()
|
||||||
} else {
|
} else {
|
||||||
// Single package
|
// Single package
|
||||||
packages_to_clean.push(scope)
|
push(packages_to_clean, scope)
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
try {
|
try {
|
||||||
var deps = pkg.gather_dependencies(scope)
|
var deps = pkg.gather_dependencies(scope)
|
||||||
arrfor(deps, function(dep) {
|
arrfor(deps, function(dep) {
|
||||||
packages_to_clean.push(dep)
|
push(packages_to_clean, dep)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Skip if can't read dependencies
|
// Skip if can't read dependencies
|
||||||
@@ -117,10 +117,10 @@ if (clean_build) {
|
|||||||
if (is_shop_scope) {
|
if (is_shop_scope) {
|
||||||
// Clean entire build and lib directories
|
// Clean entire build and lib directories
|
||||||
if (fd.is_dir(build_dir)) {
|
if (fd.is_dir(build_dir)) {
|
||||||
dirs_to_delete.push(build_dir)
|
push(dirs_to_delete, build_dir)
|
||||||
}
|
}
|
||||||
if (fd.is_dir(lib_dir)) {
|
if (fd.is_dir(lib_dir)) {
|
||||||
dirs_to_delete.push(lib_dir)
|
push(dirs_to_delete, lib_dir)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Clean specific package libraries
|
// Clean specific package libraries
|
||||||
@@ -132,17 +132,17 @@ if (clean_build) {
|
|||||||
var lib_path = lib_dir + '/' + lib_name + dylib_ext
|
var lib_path = lib_dir + '/' + lib_name + dylib_ext
|
||||||
|
|
||||||
if (fd.is_file(lib_path)) {
|
if (fd.is_file(lib_path)) {
|
||||||
files_to_delete.push(lib_path)
|
push(files_to_delete, lib_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check for .so and .dll
|
// Also check for .so and .dll
|
||||||
var so_path = lib_dir + '/' + lib_name + '.so'
|
var so_path = lib_dir + '/' + lib_name + '.so'
|
||||||
var dll_path = lib_dir + '/' + lib_name + '.dll'
|
var dll_path = lib_dir + '/' + lib_name + '.dll'
|
||||||
if (fd.is_file(so_path)) {
|
if (fd.is_file(so_path)) {
|
||||||
files_to_delete.push(so_path)
|
push(files_to_delete, so_path)
|
||||||
}
|
}
|
||||||
if (fd.is_file(dll_path)) {
|
if (fd.is_file(dll_path)) {
|
||||||
files_to_delete.push(dll_path)
|
push(files_to_delete, dll_path)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ if (clean_fetch) {
|
|||||||
if (is_shop_scope) {
|
if (is_shop_scope) {
|
||||||
// Clean entire packages directory (dangerous!)
|
// Clean entire packages directory (dangerous!)
|
||||||
if (fd.is_dir(packages_dir)) {
|
if (fd.is_dir(packages_dir)) {
|
||||||
dirs_to_delete.push(packages_dir)
|
push(dirs_to_delete, packages_dir)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Clean specific package directories
|
// Clean specific package directories
|
||||||
@@ -161,7 +161,7 @@ if (clean_fetch) {
|
|||||||
|
|
||||||
var pkg_dir = shop.get_package_dir(p)
|
var pkg_dir = shop.get_package_dir(p)
|
||||||
if (fd.is_dir(pkg_dir) || fd.is_link(pkg_dir)) {
|
if (fd.is_dir(pkg_dir) || fd.is_link(pkg_dir)) {
|
||||||
dirs_to_delete.push(pkg_dir)
|
push(dirs_to_delete, pkg_dir)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
11
clone.ce
11
clone.ce
@@ -92,12 +92,11 @@ try {
|
|||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
if (zip.is_directory(i)) continue
|
if (zip.is_directory(i)) continue
|
||||||
var filename = zip.get_filename(i)
|
var filename = zip.get_filename(i)
|
||||||
var parts = array(filename, '/')
|
var first_slash = search(filename, '/')
|
||||||
if (length(parts) <= 1) continue
|
if (first_slash == null) continue
|
||||||
|
if (first_slash + 1 >= length(filename)) continue
|
||||||
// Skip the first directory (repo-commit prefix)
|
|
||||||
parts.shift()
|
var rel_path = text(filename, first_slash + 1)
|
||||||
var rel_path = text(parts, '/')
|
|
||||||
var full_path = target_path + '/' + rel_path
|
var full_path = target_path + '/' + rel_path
|
||||||
var dir_path = fd.dirname(full_path)
|
var dir_path = fd.dirname(full_path)
|
||||||
|
|
||||||
|
|||||||
2
fd.cm
2
fd.cm
@@ -82,7 +82,7 @@ fd.globfs = function(globs, dir) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!check_neg(item_rel) && check_pos(item_rel)) {
|
if (!check_neg(item_rel) && check_pos(item_rel)) {
|
||||||
results.push(item_rel)
|
push(results, item_rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
10
fetch.ce
10
fetch.ce
@@ -39,7 +39,7 @@ if (target_pkg) {
|
|||||||
log.error("Package not found: " + target_pkg)
|
log.error("Package not found: " + target_pkg)
|
||||||
$stop()
|
$stop()
|
||||||
}
|
}
|
||||||
packages_to_fetch.push(target_pkg)
|
push(packages_to_fetch, target_pkg)
|
||||||
} else {
|
} else {
|
||||||
// Fetch all packages
|
// Fetch all packages
|
||||||
packages_to_fetch = all_packages
|
packages_to_fetch = all_packages
|
||||||
@@ -80,10 +80,10 @@ arrfor(packages_to_fetch, function(pkg) {
|
|||||||
|
|
||||||
log.console("")
|
log.console("")
|
||||||
var parts = []
|
var parts = []
|
||||||
if (downloaded_count > 0) parts.push(`${text(downloaded_count)} downloaded`)
|
if (downloaded_count > 0) push(parts, `${text(downloaded_count)} downloaded`)
|
||||||
if (cached_count > 0) parts.push(`${text(cached_count)} cached`)
|
if (cached_count > 0) push(parts, `${text(cached_count)} cached`)
|
||||||
if (fail_count > 0) parts.push(`${text(fail_count)} failed`)
|
if (fail_count > 0) push(parts, `${text(fail_count)} failed`)
|
||||||
if (length(parts) == 0) parts.push("nothing to fetch")
|
if (length(parts) == 0) push(parts, "nothing to fetch")
|
||||||
log.console("Fetch complete: " + text(parts, ", "))
|
log.console("Fetch complete: " + text(parts, ", "))
|
||||||
|
|
||||||
$stop()
|
$stop()
|
||||||
|
|||||||
12
graph.ce
12
graph.ce
@@ -97,7 +97,7 @@ function gather_graph(locator, visited) {
|
|||||||
arrfor(array(deps), function(alias) {
|
arrfor(array(deps), function(alias) {
|
||||||
var dep_locator = deps[alias]
|
var dep_locator = deps[alias]
|
||||||
add_node(dep_locator)
|
add_node(dep_locator)
|
||||||
edges.push({ from: locator, to: dep_locator, alias: alias })
|
push(edges, { from: locator, to: dep_locator, alias: alias })
|
||||||
gather_graph(dep_locator, visited)
|
gather_graph(dep_locator, visited)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ if (show_world) {
|
|||||||
var packages = shop.list_packages()
|
var packages = shop.list_packages()
|
||||||
arrfor(packages, function(p) {
|
arrfor(packages, function(p) {
|
||||||
if (p != 'core') {
|
if (p != 'core') {
|
||||||
roots.push(p)
|
push(roots, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -131,7 +131,7 @@ if (show_world) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
roots.push(target_locator)
|
push(roots, target_locator)
|
||||||
}
|
}
|
||||||
|
|
||||||
arrfor(roots, function(root) {
|
arrfor(roots, function(root) {
|
||||||
@@ -159,7 +159,7 @@ if (format == 'tree') {
|
|||||||
var children = []
|
var children = []
|
||||||
arrfor(edges, function(e) {
|
arrfor(edges, function(e) {
|
||||||
if (e.from == locator) {
|
if (e.from == locator) {
|
||||||
children.push(e)
|
push(children, e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ if (format == 'tree') {
|
|||||||
var children = []
|
var children = []
|
||||||
arrfor(edges, function(e) {
|
arrfor(edges, function(e) {
|
||||||
if (e.from == roots[i]) {
|
if (e.from == roots[i]) {
|
||||||
children.push(e)
|
push(children, e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ if (format == 'tree') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arrfor(array(nodes), function(id) {
|
arrfor(array(nodes), function(id) {
|
||||||
output.nodes.push(nodes[id])
|
push(output.nodes, nodes[id])
|
||||||
})
|
})
|
||||||
|
|
||||||
output.edges = edges
|
output.edges = edges
|
||||||
|
|||||||
@@ -88,12 +88,12 @@ function gather_packages(pkg_locator) {
|
|||||||
|
|
||||||
// Check if this is a local path that doesn't exist
|
// Check if this is a local path that doesn't exist
|
||||||
if (starts_with(pkg_locator, '/') && !fd.is_dir(pkg_locator)) {
|
if (starts_with(pkg_locator, '/') && !fd.is_dir(pkg_locator)) {
|
||||||
skipped_packages.push(pkg_locator)
|
push(skipped_packages, pkg_locator)
|
||||||
log.console(" Skipping missing local package: " + pkg_locator)
|
log.console(" Skipping missing local package: " + pkg_locator)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
packages_to_install.push(pkg_locator)
|
push(packages_to_install, pkg_locator)
|
||||||
|
|
||||||
// Try to read dependencies
|
// Try to read dependencies
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ $_.start = function start(cb, program) {
|
|||||||
program,
|
program,
|
||||||
}
|
}
|
||||||
greeters[id] = cb
|
greeters[id] = cb
|
||||||
message_queue.push({ startup })
|
push(message_queue, { startup })
|
||||||
}
|
}
|
||||||
|
|
||||||
// stops an underling or self.
|
// stops an underling or self.
|
||||||
@@ -517,7 +517,7 @@ $_.couple = function couple(actor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function actor_prep(actor, send) {
|
function actor_prep(actor, send) {
|
||||||
message_queue.push({actor,send});
|
push(message_queue, {actor,send});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a message immediately without queuing
|
// Send a message immediately without queuing
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ function inject_bindings_code(inject) {
|
|||||||
for (var i = 0; i < length(inject); i++) {
|
for (var i = 0; i < length(inject); i++) {
|
||||||
var inj = inject[i]
|
var inj = inject[i]
|
||||||
var key = trim(inj, '$')
|
var key = trim(inj, '$')
|
||||||
lines.push(`var $${key} = env["${key}"];`)
|
push(lines, `var $${key} = env["${key}"];`)
|
||||||
}
|
}
|
||||||
return text(lines, '\n')
|
return text(lines, '\n')
|
||||||
}
|
}
|
||||||
@@ -1108,11 +1108,10 @@ function install_zip(zip_blob, target_dir) {
|
|||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
if (zip.is_directory(i)) continue
|
if (zip.is_directory(i)) continue
|
||||||
var filename = zip.get_filename(i)
|
var filename = zip.get_filename(i)
|
||||||
var parts = array(filename, '/')
|
var slash_pos = search(filename, '/')
|
||||||
if (length(parts) <= 1) continue
|
if (slash_pos == null) continue
|
||||||
|
if (slash_pos + 1 >= length(filename)) continue
|
||||||
parts.shift()
|
var rel_path = text(filename, slash_pos + 1)
|
||||||
var rel_path = text(parts, '/')
|
|
||||||
var full_path = target_dir + '/' + rel_path
|
var full_path = target_dir + '/' + rel_path
|
||||||
var dir_path = fd.dirname(full_path)
|
var dir_path = fd.dirname(full_path)
|
||||||
|
|
||||||
@@ -1214,7 +1213,7 @@ function get_package_scripts(package)
|
|||||||
for (var i = 0; i < length(files); i++) {
|
for (var i = 0; i < length(files); i++) {
|
||||||
var file = files[i]
|
var file = files[i]
|
||||||
if (ends_with(file, '.cm') || ends_with(file, '.ce')) {
|
if (ends_with(file, '.cm') || ends_with(file, '.ce')) {
|
||||||
scripts.push(file)
|
push(scripts, file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1289,7 +1288,7 @@ Shop.audit_packages = function() {
|
|||||||
if (package == 'core') return
|
if (package == 'core') return
|
||||||
if (fd.is_dir(package)) return
|
if (fd.is_dir(package)) return
|
||||||
if (fetch_remote_hash(package)) return
|
if (fetch_remote_hash(package)) return
|
||||||
bad.push(package)
|
push(bad, package)
|
||||||
})
|
})
|
||||||
|
|
||||||
return bad
|
return bad
|
||||||
|
|||||||
6
link.cm
6
link.cm
@@ -222,11 +222,11 @@ Link.sync_all = function(shop) {
|
|||||||
// Validate target exists
|
// Validate target exists
|
||||||
var link_target = resolve_link_target(target)
|
var link_target = resolve_link_target(target)
|
||||||
if (!fd.is_dir(link_target)) {
|
if (!fd.is_dir(link_target)) {
|
||||||
errors.push(canonical + ': target ' + link_target + ' does not exist')
|
push(errors, canonical + ': target ' + link_target + ' does not exist')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!fd.is_file(link_target + '/cell.toml')) {
|
if (!fd.is_file(link_target + '/cell.toml')) {
|
||||||
errors.push(canonical + ': target ' + link_target + ' is not a valid package')
|
push(errors, canonical + ': target ' + link_target + ' is not a valid package')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ Link.sync_all = function(shop) {
|
|||||||
|
|
||||||
count++
|
count++
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errors.push(canonical + ': ' + e.message)
|
push(errors, canonical + ': ' + e.message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
14
list.ce
14
list.ce
@@ -80,16 +80,16 @@ function print_deps(ctx, indent) {
|
|||||||
// Add status indicators
|
// Add status indicators
|
||||||
var status = []
|
var status = []
|
||||||
if (link_target) {
|
if (link_target) {
|
||||||
status.push("linked -> " + link_target)
|
push(status, "linked -> " + link_target)
|
||||||
}
|
}
|
||||||
if (lock_entry && lock_entry.commit) {
|
if (lock_entry && lock_entry.commit) {
|
||||||
status.push("@" + text(lock_entry.commit, 0, 8))
|
push(status, "@" + text(lock_entry.commit, 0, 8))
|
||||||
}
|
}
|
||||||
if (lock_entry && lock_entry.type == 'local') {
|
if (lock_entry && lock_entry.type == 'local') {
|
||||||
status.push("local")
|
push(status, "local")
|
||||||
}
|
}
|
||||||
if (!lock_entry) {
|
if (!lock_entry) {
|
||||||
status.push("not installed")
|
push(status, "not installed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length(status) > 0) {
|
if (length(status) > 0) {
|
||||||
@@ -127,11 +127,11 @@ if (mode == 'local') {
|
|||||||
var link_target = links[p]
|
var link_target = links[p]
|
||||||
|
|
||||||
if (link_target) {
|
if (link_target) {
|
||||||
linked_pkgs.push(p)
|
push(linked_pkgs, p)
|
||||||
} else if (lock_entry && lock_entry.type == 'local') {
|
} else if (lock_entry && lock_entry.type == 'local') {
|
||||||
local_pkgs.push(p)
|
push(local_pkgs, p)
|
||||||
} else {
|
} else {
|
||||||
remote_pkgs.push(p)
|
push(remote_pkgs, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
6
pack.ce
6
pack.ce
@@ -88,9 +88,9 @@ var packages = ['core']
|
|||||||
var deps = pkg_tools.gather_dependencies(target_package)
|
var deps = pkg_tools.gather_dependencies(target_package)
|
||||||
|
|
||||||
for (var i = 0; i < length(deps); i++) {
|
for (var i = 0; i < length(deps); i++) {
|
||||||
packages.push(deps[i])
|
push(packages, deps[i])
|
||||||
}
|
}
|
||||||
packages.push(target_package)
|
push(packages, target_package)
|
||||||
|
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
var unique_packages = []
|
var unique_packages = []
|
||||||
@@ -98,7 +98,7 @@ var seen = {}
|
|||||||
for (var i = 0; i < length(packages); i++) {
|
for (var i = 0; i < length(packages); i++) {
|
||||||
if (!seen[packages[i]]) {
|
if (!seen[packages[i]]) {
|
||||||
seen[packages[i]] = true
|
seen[packages[i]] = true
|
||||||
unique_packages.push(packages[i])
|
push(unique_packages, packages[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packages = unique_packages
|
packages = unique_packages
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ package.list_files = function(pkg) {
|
|||||||
if (st.isDirectory) {
|
if (st.isDirectory) {
|
||||||
walk(full_path, rel_path)
|
walk(full_path, rel_path)
|
||||||
} else {
|
} else {
|
||||||
files.push(rel_path)
|
push(files, rel_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ package.list_modules = function(name) {
|
|||||||
var modules = []
|
var modules = []
|
||||||
for (var i = 0; i < length(files); i++) {
|
for (var i = 0; i < length(files); i++) {
|
||||||
if (ends_with(files[i], '.cm')) {
|
if (ends_with(files[i], '.cm')) {
|
||||||
modules.push(text(files[i], 0, -3))
|
push(modules, text(files[i], 0, -3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modules
|
return modules
|
||||||
@@ -250,7 +250,7 @@ package.list_programs = function(name) {
|
|||||||
var programs = []
|
var programs = []
|
||||||
for (var i = 0; i < length(files); i++) {
|
for (var i = 0; i < length(files); i++) {
|
||||||
if (ends_with(files[i], '.ce')) {
|
if (ends_with(files[i], '.ce')) {
|
||||||
programs.push(text(files[i], 0, -3))
|
push(programs, text(files[i], 0, -3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return programs
|
return programs
|
||||||
@@ -346,7 +346,7 @@ package.get_c_files = function(name, target, exclude_main) {
|
|||||||
var basename = fd.basename(selected)
|
var basename = fd.basename(selected)
|
||||||
if (basename == 'main.c' || starts_with(basename, 'main_')) return
|
if (basename == 'main.c' || starts_with(basename, 'main_')) return
|
||||||
}
|
}
|
||||||
result.push(selected)
|
push(result, selected)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ if (!is_array(arg) || length(arg) < 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; i < length(arg) - 1; i++) {
|
for (; i < length(arg) - 1; i++) {
|
||||||
sources.push(arg[i])
|
push(sources, arg[i])
|
||||||
}
|
}
|
||||||
archive = arg[length(arg) - 1]
|
archive = arg[length(arg) - 1]
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ if (prune) {
|
|||||||
arrfor(all_packages, function(p) {
|
arrfor(all_packages, function(p) {
|
||||||
if (p == 'core') return
|
if (p == 'core') return
|
||||||
if (!needed[p] && find(packages_to_remove, p) == null) {
|
if (!needed[p] && find(packages_to_remove, p) == null) {
|
||||||
packages_to_remove.push(p)
|
push(packages_to_remove, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
10
resolve.ce
10
resolve.ce
@@ -145,11 +145,11 @@ for (var i = 0; i < length(sorted); i++) {
|
|||||||
|
|
||||||
// Format output
|
// Format output
|
||||||
var status_parts = []
|
var status_parts = []
|
||||||
if (is_linked) status_parts.push("linked")
|
if (is_linked) push(status_parts, "linked")
|
||||||
if (is_local) status_parts.push("local")
|
if (is_local) push(status_parts, "local")
|
||||||
if (!is_in_lock) status_parts.push("not in lock")
|
if (!is_in_lock) push(status_parts, "not in lock")
|
||||||
if (!is_fetched) status_parts.push("not fetched")
|
if (!is_fetched) push(status_parts, "not fetched")
|
||||||
if (is_built) status_parts.push("built")
|
if (is_built) push(status_parts, "built")
|
||||||
|
|
||||||
var commit_str = ""
|
var commit_str = ""
|
||||||
if (lock_entry && lock_entry.commit) {
|
if (lock_entry && lock_entry.commit) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var packages = shop.list_packages()
|
|||||||
arrfor(packages, function(package_name) {
|
arrfor(packages, function(package_name) {
|
||||||
// Check if package name matches
|
// Check if package name matches
|
||||||
if (search(package_name, query) != null) {
|
if (search(package_name, query) != null) {
|
||||||
found_packages.push(package_name)
|
push(found_packages, package_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search modules and actors within the package
|
// Search modules and actors within the package
|
||||||
@@ -30,14 +30,14 @@ arrfor(packages, function(package_name) {
|
|||||||
var modules = pkg.list_modules(package_name)
|
var modules = pkg.list_modules(package_name)
|
||||||
arrfor(modules, function(mod) {
|
arrfor(modules, function(mod) {
|
||||||
if (search(mod, query) != null) {
|
if (search(mod, query) != null) {
|
||||||
found_modules.push(package_name + ':' + mod)
|
push(found_modules, package_name + ':' + mod)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var actors = pkg.list_programs(package_name)
|
var actors = pkg.list_programs(package_name)
|
||||||
arrfor(actors, function(actor) {
|
arrfor(actors, function(actor) {
|
||||||
if (search(actor, query) != null) {
|
if (search(actor, query) != null) {
|
||||||
found_actors.push(package_name + ':' + actor)
|
push(found_actors, package_name + ':' + actor)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
226
source/quickjs.c
226
source/quickjs.c
@@ -27078,11 +27078,6 @@ static JSValue js_error_toString(JSContext *ctx, JSValueConst this_val,
|
|||||||
return JS_ConcatString(ctx, name, msg);
|
return JS_ConcatString(ctx, name, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_error_proto_funcs[] = {
|
|
||||||
JS_PROP_STRING_DEF("name", "Error", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
|
|
||||||
JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Array */
|
/* Array */
|
||||||
|
|
||||||
static int JS_CopySubArray(JSContext *ctx,
|
static int JS_CopySubArray(JSContext *ctx,
|
||||||
@@ -27182,27 +27177,6 @@ fail:
|
|||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue JS_ArraySpeciesCreate(JSContext *ctx, JSValueConst obj,
|
|
||||||
JSValueConst len_val)
|
|
||||||
{
|
|
||||||
/* Always use the array constructor - no species/constructor lookup */
|
|
||||||
return js_array_constructor(ctx, JS_NULL, 1, &len_val);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int JS_isConcatSpreadable(JSContext *ctx, JSValueConst obj)
|
|
||||||
{
|
|
||||||
JSValue val;
|
|
||||||
|
|
||||||
if (!JS_IsObject(obj))
|
|
||||||
return FALSE;
|
|
||||||
val = JS_GetProperty(ctx, obj, JS_ATOM_Symbol_isConcatSpreadable);
|
|
||||||
if (JS_IsException(val))
|
|
||||||
return -1;
|
|
||||||
if (!JS_IsNull(val))
|
|
||||||
return JS_ToBoolFree(ctx, val);
|
|
||||||
return JS_IsArray(ctx, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSValue js_array_includes(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_array_includes(JSContext *ctx, JSValueConst this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValueConst *argv)
|
||||||
{
|
{
|
||||||
@@ -27343,113 +27317,6 @@ static JSValue js_array_push(JSContext *ctx, JSValueConst this_val,
|
|||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_array_slice(JSContext *ctx, JSValueConst this_val,
|
|
||||||
int argc, JSValueConst *argv, int splice)
|
|
||||||
{
|
|
||||||
JSValue obj, arr, val, len_val;
|
|
||||||
int64_t len, start, k, final, n, count, del_count, new_len;
|
|
||||||
int kPresent;
|
|
||||||
JSValue *arrp;
|
|
||||||
uint32_t count32, i, item_count;
|
|
||||||
|
|
||||||
arr = JS_NULL;
|
|
||||||
obj = JS_ToObject(ctx, this_val);
|
|
||||||
if (js_get_length64(ctx, &len, obj))
|
|
||||||
goto exception;
|
|
||||||
|
|
||||||
if (JS_ToInt64Clamp(ctx, &start, argv[0], 0, len, len))
|
|
||||||
goto exception;
|
|
||||||
|
|
||||||
if (splice) {
|
|
||||||
if (argc == 0) {
|
|
||||||
item_count = 0;
|
|
||||||
del_count = 0;
|
|
||||||
} else
|
|
||||||
if (argc == 1) {
|
|
||||||
item_count = 0;
|
|
||||||
del_count = len - start;
|
|
||||||
} else {
|
|
||||||
item_count = argc - 2;
|
|
||||||
if (JS_ToInt64Clamp(ctx, &del_count, argv[1], 0, len - start, 0))
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
if (len + item_count - del_count > MAX_SAFE_INTEGER) {
|
|
||||||
JS_ThrowTypeError(ctx, "Array loo long");
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
count = del_count;
|
|
||||||
} else {
|
|
||||||
item_count = 0; /* avoid warning */
|
|
||||||
final = len;
|
|
||||||
if (!JS_IsNull(argv[1])) {
|
|
||||||
if (JS_ToInt64Clamp(ctx, &final, argv[1], 0, len, len))
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
count = max_int64(final - start, 0);
|
|
||||||
}
|
|
||||||
len_val = JS_NewInt64(ctx, count);
|
|
||||||
arr = JS_ArraySpeciesCreate(ctx, obj, len_val);
|
|
||||||
JS_FreeValue(ctx, len_val);
|
|
||||||
if (JS_IsException(arr))
|
|
||||||
goto exception;
|
|
||||||
|
|
||||||
k = start;
|
|
||||||
final = start + count;
|
|
||||||
n = 0;
|
|
||||||
/* The fast array test on arr ensures that
|
|
||||||
JS_CreateDataPropertyUint32() won't modify obj in case arr is
|
|
||||||
an exotic object */
|
|
||||||
/* Special case fast arrays */
|
|
||||||
if (js_get_fast_array(ctx, obj, &arrp, &count32) &&
|
|
||||||
js_is_fast_array(ctx, arr)) {
|
|
||||||
/* XXX: should share code with fast array constructor */
|
|
||||||
for (; k < final && k < count32; k++, n++) {
|
|
||||||
if (JS_CreateDataPropertyUint32(ctx, arr, n, JS_DupValue(ctx, arrp[k]), JS_PROP_THROW) < 0)
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Copy the remaining elements if any (handle case of inherited properties) */
|
|
||||||
for (; k < final; k++, n++) {
|
|
||||||
kPresent = JS_TryGetPropertyInt64(ctx, obj, k, &val);
|
|
||||||
if (kPresent < 0)
|
|
||||||
goto exception;
|
|
||||||
if (kPresent) {
|
|
||||||
if (JS_CreateDataPropertyUint32(ctx, arr, n, val, JS_PROP_THROW) < 0)
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (JS_SetProperty(ctx, arr, JS_ATOM_length, JS_NewInt64(ctx, n)) < 0)
|
|
||||||
goto exception;
|
|
||||||
|
|
||||||
if (splice) {
|
|
||||||
new_len = len + item_count - del_count;
|
|
||||||
if (item_count != del_count) {
|
|
||||||
if (JS_CopySubArray(ctx, obj, start + item_count,
|
|
||||||
start + del_count, len - (start + del_count),
|
|
||||||
item_count <= del_count ? +1 : -1) < 0)
|
|
||||||
goto exception;
|
|
||||||
|
|
||||||
for (k = len; k-- > new_len; ) {
|
|
||||||
if (JS_DeletePropertyInt64(ctx, obj, k, JS_PROP_THROW) < 0)
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < item_count; i++) {
|
|
||||||
if (JS_SetPropertyInt64(ctx, obj, start + i, JS_DupValue(ctx, argv[i + 2])) < 0)
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
if (JS_SetProperty(ctx, obj, JS_ATOM_length, JS_NewInt64(ctx, new_len)) < 0)
|
|
||||||
goto exception;
|
|
||||||
}
|
|
||||||
JS_FreeValue(ctx, obj);
|
|
||||||
return arr;
|
|
||||||
|
|
||||||
exception:
|
|
||||||
JS_FreeValue(ctx, obj);
|
|
||||||
JS_FreeValue(ctx, arr);
|
|
||||||
return JS_EXCEPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target,
|
static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target,
|
||||||
JSValueConst source, int64_t sourceLen,
|
JSValueConst source, int64_t sourceLen,
|
||||||
int64_t targetIndex, int depth,
|
int64_t targetIndex, int depth,
|
||||||
@@ -27529,15 +27396,6 @@ static JSValue js_create_array(JSContext *ctx, int len, JSValueConst *tab)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_array_proto_funcs[] = {
|
|
||||||
JS_CFUNC_MAGIC_DEF("pop", 0, js_array_pop, 0 ),
|
|
||||||
JS_CFUNC_MAGIC_DEF("push", 1, js_array_push, 0 ),
|
|
||||||
JS_CFUNC_MAGIC_DEF("shift", 0, js_array_pop, 1 ),
|
|
||||||
JS_CFUNC_MAGIC_DEF("unshift", 1, js_array_push, 1 ),
|
|
||||||
JS_CFUNC_MAGIC_DEF("slice", 2, js_array_slice, 0 ),
|
|
||||||
JS_CFUNC_MAGIC_DEF("splice", 2, js_array_slice, 1 ),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* String */
|
/* String */
|
||||||
static int js_string_get_own_property(JSContext *ctx,
|
static int js_string_get_own_property(JSContext *ctx,
|
||||||
JSPropertyDescriptor *desc,
|
JSPropertyDescriptor *desc,
|
||||||
@@ -32761,6 +32619,71 @@ static JSValue js_cell_reverse(JSContext *ctx, JSValueConst this_val,
|
|||||||
* proto() function - get prototype of an object
|
* proto() function - get prototype of an object
|
||||||
* ============================================================================ */
|
* ============================================================================ */
|
||||||
|
|
||||||
|
static JSValue js_cell_pop(JSContext *ctx, JSValueConst this_val,
|
||||||
|
int argc, JSValueConst *argv)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return JS_NULL;
|
||||||
|
|
||||||
|
JSValue obj = argv[0];
|
||||||
|
if (!JS_IsArray(ctx, obj))
|
||||||
|
return JS_NULL;
|
||||||
|
|
||||||
|
JSValue length_val = JS_GetPropertyStr(ctx, obj, "length");
|
||||||
|
int64_t len;
|
||||||
|
if (JS_ToInt64(ctx, &len, length_val) < 0) {
|
||||||
|
JS_FreeValue(ctx, length_val);
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
}
|
||||||
|
JS_FreeValue(ctx, length_val);
|
||||||
|
|
||||||
|
if (len <= 0)
|
||||||
|
return JS_NULL;
|
||||||
|
|
||||||
|
JSValue val = JS_GetPropertyInt64(ctx, obj, len - 1);
|
||||||
|
if (JS_IsException(val))
|
||||||
|
return val;
|
||||||
|
|
||||||
|
if (JS_DeletePropertyInt64(ctx, obj, len - 1, JS_PROP_THROW) < 0) {
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JS_SetPropertyStr(ctx, obj, "length", JS_NewInt64(ctx, len - 1)) < 0) {
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JSValue js_cell_push(JSContext *ctx, JSValueConst this_val,
|
||||||
|
int argc, JSValueConst *argv)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return JS_NULL;
|
||||||
|
|
||||||
|
JSValue obj = argv[0];
|
||||||
|
if (!JS_IsArray(ctx, obj))
|
||||||
|
return JS_NULL;
|
||||||
|
|
||||||
|
JSValue length_val = JS_GetPropertyStr(ctx, obj, "length");
|
||||||
|
int64_t len;
|
||||||
|
if (JS_ToInt64(ctx, &len, length_val) < 0) {
|
||||||
|
JS_FreeValue(ctx, length_val);
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
}
|
||||||
|
JS_FreeValue(ctx, length_val);
|
||||||
|
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
if (JS_SetPropertyInt64(ctx, obj, len, JS_DupValue(ctx, argv[i])) < 0)
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JS_NewInt64(ctx, len);
|
||||||
|
}
|
||||||
|
|
||||||
static JSValue js_cell_proto(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_cell_proto(JSContext *ctx, JSValueConst this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValueConst *argv)
|
||||||
{
|
{
|
||||||
@@ -33251,10 +33174,6 @@ static void JS_AddIntrinsicBasicObjects(JSContext *ctx)
|
|||||||
ctx->class_proto[JS_CLASS_BYTECODE_FUNCTION] = JS_DupValue(ctx, ctx->function_proto);
|
ctx->class_proto[JS_CLASS_BYTECODE_FUNCTION] = JS_DupValue(ctx, ctx->function_proto);
|
||||||
ctx->class_proto[JS_CLASS_ERROR] = JS_NewObject(ctx);
|
ctx->class_proto[JS_CLASS_ERROR] = JS_NewObject(ctx);
|
||||||
|
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ERROR],
|
|
||||||
js_error_proto_funcs,
|
|
||||||
countof(js_error_proto_funcs));
|
|
||||||
|
|
||||||
for(i = 0; i < JS_NATIVE_ERROR_COUNT; i++) {
|
for(i = 0; i < JS_NATIVE_ERROR_COUNT; i++) {
|
||||||
proto = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ERROR]);
|
proto = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ERROR]);
|
||||||
JS_DefinePropertyValue(ctx, proto, JS_ATOM_name,
|
JS_DefinePropertyValue(ctx, proto, JS_ATOM_name,
|
||||||
@@ -33325,10 +33244,6 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Array */
|
/* Array */
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY],
|
|
||||||
js_array_proto_funcs,
|
|
||||||
countof(js_array_proto_funcs));
|
|
||||||
|
|
||||||
obj = JS_NewGlobalCConstructor(ctx, "Array", js_array_constructor, 1,
|
obj = JS_NewGlobalCConstructor(ctx, "Array", js_array_constructor, 1,
|
||||||
ctx->class_proto[JS_CLASS_ARRAY]);
|
ctx->class_proto[JS_CLASS_ARRAY]);
|
||||||
ctx->array_ctor = JS_DupValue(ctx, obj);
|
ctx->array_ctor = JS_DupValue(ctx, obj);
|
||||||
@@ -33584,6 +33499,17 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
|||||||
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "pi",
|
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "pi",
|
||||||
JS_NewFloat64(ctx, 3.14159265358979323846264338327950288419716939937510),
|
JS_NewFloat64(ctx, 3.14159265358979323846264338327950288419716939937510),
|
||||||
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||||
|
|
||||||
|
/* push() - add element to end of array */
|
||||||
|
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "push",
|
||||||
|
JS_NewCFunction(ctx, js_cell_push, "push", 2),
|
||||||
|
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||||
|
|
||||||
|
/* pop() - remove and return last element of array */
|
||||||
|
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "pop",
|
||||||
|
JS_NewCFunction(ctx, js_cell_pop, "pop", 1),
|
||||||
|
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
42
test.ce
42
test.ce
@@ -191,7 +191,7 @@ function collect_actor_tests(package_name, specific_test) {
|
|||||||
if (test_base != match_base) continue
|
if (test_base != match_base) continue
|
||||||
}
|
}
|
||||||
|
|
||||||
actor_tests.push({
|
push(actor_tests,{
|
||||||
package: package_name || "local",
|
package: package_name || "local",
|
||||||
file: f,
|
file: f,
|
||||||
path: prefix + '/' + f
|
path: prefix + '/' + f
|
||||||
@@ -219,12 +219,12 @@ function spawn_actor_test(test_info) {
|
|||||||
// Spawn the actor test - it should send back results
|
// Spawn the actor test - it should send back results
|
||||||
var actor_path = text(test_info.path, 0, -3) // remove .ce
|
var actor_path = text(test_info.path, 0, -3) // remove .ce
|
||||||
entry.actor = $start(actor_path)
|
entry.actor = $start(actor_path)
|
||||||
pending_actor_tests.push(entry)
|
push(pending_actor_tests, entry)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
entry.status = "failed"
|
entry.status = "failed"
|
||||||
entry.error = { message: `Failed to spawn actor: ${e}` }
|
entry.error = { message: `Failed to spawn actor: ${e}` }
|
||||||
entry.duration_ns = 0
|
entry.duration_ns = 0
|
||||||
actor_test_results.push(entry)
|
push(actor_test_results, entry)
|
||||||
log.console(` FAIL ${test_name}: `)
|
log.console(` FAIL ${test_name}: `)
|
||||||
log.error(e)
|
log.error(e)
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ function run_tests(package_name, specific_test) {
|
|||||||
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
|
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
|
||||||
if (test_name != match_base) continue
|
if (test_name != match_base) continue
|
||||||
}
|
}
|
||||||
test_files.push(f)
|
push(test_files, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,11 +287,11 @@ function run_tests(package_name, specific_test) {
|
|||||||
|
|
||||||
var tests = []
|
var tests = []
|
||||||
if (is_function(test_mod)) {
|
if (is_function(test_mod)) {
|
||||||
tests.push({name: 'main', fn: test_mod})
|
push(tests, {name: 'main', fn: test_mod})
|
||||||
} else if (is_object(test_mod)) {
|
} else if (is_object(test_mod)) {
|
||||||
arrfor(array(test_mod), function(k) {
|
arrfor(array(test_mod), function(k) {
|
||||||
if (is_function(test_mod[k])) {
|
if (is_function(test_mod[k])) {
|
||||||
tests.push({name: k, fn: test_mod[k]})
|
push(tests, {name: k, fn: test_mod[k]})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ function run_tests(package_name, specific_test) {
|
|||||||
var end_time = time.number()
|
var end_time = time.number()
|
||||||
test_entry.duration_ns = round((end_time - start_time) * 1000000000)
|
test_entry.duration_ns = round((end_time - start_time) * 1000000000)
|
||||||
|
|
||||||
file_result.tests.push(test_entry)
|
push(file_result.tests, test_entry)
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,12 +358,12 @@ function run_tests(package_name, specific_test) {
|
|||||||
duration_ns: 0,
|
duration_ns: 0,
|
||||||
error: { message: `Error loading module: ${e}` }
|
error: { message: `Error loading module: ${e}` }
|
||||||
}
|
}
|
||||||
file_result.tests.push(test_entry)
|
push(file_result.tests, test_entry)
|
||||||
pkg_result.failed++
|
pkg_result.failed++
|
||||||
file_result.failed++
|
file_result.failed++
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
}
|
}
|
||||||
pkg_result.files.push(file_result)
|
push(pkg_result.files, file_result)
|
||||||
}
|
}
|
||||||
return pkg_result
|
return pkg_result
|
||||||
}
|
}
|
||||||
@@ -374,18 +374,18 @@ var all_actor_tests = []
|
|||||||
if (all_pkgs) {
|
if (all_pkgs) {
|
||||||
// Run local first if we're in a valid package
|
// Run local first if we're in a valid package
|
||||||
if (is_valid_package('.')) {
|
if (is_valid_package('.')) {
|
||||||
all_results.push(run_tests(null, null))
|
push(all_results, run_tests(null, null))
|
||||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(null, null))
|
all_actor_tests = array(all_actor_tests, collect_actor_tests(null, null))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then all packages in lock
|
// Then all packages in lock
|
||||||
var packages = shop.list_packages()
|
var packages = shop.list_packages()
|
||||||
for (var i = 0; i < length(packages); i++) {
|
for (var i = 0; i < length(packages); i++) {
|
||||||
all_results.push(run_tests(packages[i], null))
|
push(all_results, run_tests(packages[i], null))
|
||||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(packages[i], null))
|
all_actor_tests = array(all_actor_tests, collect_actor_tests(packages[i], null))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
all_results.push(run_tests(target_pkg, target_test))
|
push(all_results, run_tests(target_pkg, target_test))
|
||||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(target_pkg, target_test))
|
all_actor_tests = array(all_actor_tests, collect_actor_tests(target_pkg, target_test))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ function handle_actor_message(msg) {
|
|||||||
if (found_idx == -1) return
|
if (found_idx == -1) return
|
||||||
|
|
||||||
var base_entry = pending_actor_tests[found_idx]
|
var base_entry = pending_actor_tests[found_idx]
|
||||||
pending_actor_tests.splice(found_idx, 1)
|
pending_actor_tests = array(array(pending_actor_tests, 0, found_idx), array(pending_actor_tests, found_idx + 1))
|
||||||
|
|
||||||
var end_time = time.number()
|
var end_time = time.number()
|
||||||
var duration_ns = round((end_time - base_entry.start_time) * 1000000000)
|
var duration_ns = round((end_time - base_entry.start_time) * 1000000000)
|
||||||
@@ -447,7 +447,7 @@ function handle_actor_message(msg) {
|
|||||||
log.console(` FAIL ${entry.test}: ${entry.error.message}`)
|
log.console(` FAIL ${entry.test}: ${entry.error.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
actor_test_results.push(entry)
|
push(actor_test_results, entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
check_completion()
|
check_completion()
|
||||||
@@ -462,19 +462,19 @@ function check_timeouts() {
|
|||||||
var entry = pending_actor_tests[i]
|
var entry = pending_actor_tests[i]
|
||||||
var elapsed_ms = (now - entry.start_time) * 1000
|
var elapsed_ms = (now - entry.start_time) * 1000
|
||||||
if (elapsed_ms > ACTOR_TEST_TIMEOUT) {
|
if (elapsed_ms > ACTOR_TEST_TIMEOUT) {
|
||||||
timed_out.push(i)
|
push(timed_out, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < length(timed_out); i++) {
|
for (var i = 0; i < length(timed_out); i++) {
|
||||||
var idx = timed_out[i]
|
var idx = timed_out[i]
|
||||||
var entry = pending_actor_tests[idx]
|
var entry = pending_actor_tests[idx]
|
||||||
pending_actor_tests.splice(idx, 1)
|
pending_actor_tests = array(array(pending_actor_tests, 0, idx), array(pending_actor_tests, idx + 1))
|
||||||
|
|
||||||
entry.status = "failed"
|
entry.status = "failed"
|
||||||
entry.error = { message: "Test timed out" }
|
entry.error = { message: "Test timed out" }
|
||||||
entry.duration_ns = ACTOR_TEST_TIMEOUT * 1000000
|
entry.duration_ns = ACTOR_TEST_TIMEOUT * 1000000
|
||||||
actor_test_results.push(entry)
|
push(actor_test_results, entry)
|
||||||
log.console(` TIMEOUT ${entry.test}`)
|
log.console(` TIMEOUT ${entry.test}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ function finalize_results() {
|
|||||||
}
|
}
|
||||||
if (!pkg_result) {
|
if (!pkg_result) {
|
||||||
pkg_result = { package: r.package, files: [], total: 0, passed: 0, failed: 0 }
|
pkg_result = { package: r.package, files: [], total: 0, passed: 0, failed: 0 }
|
||||||
all_results.push(pkg_result)
|
push(all_results, pkg_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_result = null
|
var file_result = null
|
||||||
@@ -519,10 +519,10 @@ function finalize_results() {
|
|||||||
}
|
}
|
||||||
if (!file_result) {
|
if (!file_result) {
|
||||||
file_result = { name: r.file, tests: [], passed: 0, failed: 0 }
|
file_result = { name: r.file, tests: [], passed: 0, failed: 0 }
|
||||||
pkg_result.files.push(file_result)
|
push(pkg_result.files, file_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
file_result.tests.push(r)
|
push(file_result.tests, r)
|
||||||
pkg_result.total++
|
pkg_result.total++
|
||||||
if (r.status == "passed") {
|
if (r.status == "passed") {
|
||||||
pkg_result.passed++
|
pkg_result.passed++
|
||||||
@@ -639,7 +639,7 @@ Total: ${totals.total}, Passed: ${totals.passed}, Failed: ${totals.failed}
|
|||||||
for (var j = 0; j < length(pkg_res.files); j++) {
|
for (var j = 0; j < length(pkg_res.files); j++) {
|
||||||
var f = pkg_res.files[j]
|
var f = pkg_res.files[j]
|
||||||
for (var k = 0; k < length(f.tests); k++) {
|
for (var k = 0; k < length(f.tests); k++) {
|
||||||
pkg_tests.push(f.tests[k])
|
push(pkg_tests, f.tests[k])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function makeTest(test) {
|
|||||||
|
|
||||||
var testarr = []
|
var testarr = []
|
||||||
for (var i = 0; i < 500; i++) {
|
for (var i = 0; i < 500; i++) {
|
||||||
testarr.push(1)
|
push(testarr, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCases = [
|
var testCases = [
|
||||||
|
|||||||
@@ -561,14 +561,14 @@ return {
|
|||||||
|
|
||||||
test_array_push: function() {
|
test_array_push: function() {
|
||||||
var arr = [1, 2]
|
var arr = [1, 2]
|
||||||
arr.push(3)
|
push(arr, 3)
|
||||||
if (length(arr) != 3) throw "array push length failed"
|
if (length(arr) != 3) throw "array push length failed"
|
||||||
if (arr[2] != 3) throw "array push value failed"
|
if (arr[2] != 3) throw "array push value failed"
|
||||||
},
|
},
|
||||||
|
|
||||||
test_array_pop: function() {
|
test_array_pop: function() {
|
||||||
var arr = [1, 2, 3]
|
var arr = [1, 2, 3]
|
||||||
var val = arr.pop()
|
var val = pop(arr)
|
||||||
if (val != 3) throw "array pop value failed"
|
if (val != 3) throw "array pop value failed"
|
||||||
if (length(arr) != 2) throw "array pop length failed"
|
if (length(arr) != 2) throw "array pop length failed"
|
||||||
},
|
},
|
||||||
@@ -1474,39 +1474,6 @@ return {
|
|||||||
// ARRAY METHODS
|
// ARRAY METHODS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
test_array_shift: function() {
|
|
||||||
var arr = [1, 2, 3]
|
|
||||||
var first = arr.shift()
|
|
||||||
if (first != 1) throw "array shift value failed"
|
|
||||||
if (length(arr) != 2) throw "array shift length failed"
|
|
||||||
if (arr[0] != 2) throw "array shift remaining failed"
|
|
||||||
},
|
|
||||||
|
|
||||||
test_array_unshift: function() {
|
|
||||||
var arr = [2, 3]
|
|
||||||
arr.unshift(1)
|
|
||||||
if (length(arr) != 3) throw "array unshift length failed"
|
|
||||||
if (arr[0] != 1) throw "array unshift value failed"
|
|
||||||
},
|
|
||||||
|
|
||||||
test_array_splice: function() {
|
|
||||||
var arr = [1, 2, 3, 4, 5]
|
|
||||||
var removed = arr.splice(1, 2)
|
|
||||||
if (length(removed) != 2) throw "array splice removed length failed"
|
|
||||||
if (removed[0] != 2) throw "array splice removed values failed"
|
|
||||||
if (length(arr) != 3) throw "array splice remaining length failed"
|
|
||||||
if (arr[1] != 4) throw "array splice remaining values failed"
|
|
||||||
},
|
|
||||||
|
|
||||||
test_array_slice: function() {
|
|
||||||
var arr = [1, 2, 3, 4, 5]
|
|
||||||
var sliced = array(arr, 1, 3)
|
|
||||||
if (length(sliced) != 2) throw "array slice length failed"
|
|
||||||
if (sliced[0] != 2) throw "array slice first failed"
|
|
||||||
if (sliced[1] != 3) throw "array slice second failed"
|
|
||||||
if (length(arr) != 5) throw "array slice should not mutate original"
|
|
||||||
},
|
|
||||||
|
|
||||||
test_array_concat: function() {
|
test_array_concat: function() {
|
||||||
var arr1 = [1, 2]
|
var arr1 = [1, 2]
|
||||||
var arr2 = [3, 4]
|
var arr2 = [3, 4]
|
||||||
@@ -2102,7 +2069,7 @@ return {
|
|||||||
test_function_proxy_args_array_is_real_array: function() {
|
test_function_proxy_args_array_is_real_array: function() {
|
||||||
var proxy = function(name, args) {
|
var proxy = function(name, args) {
|
||||||
if (!is_array(args)) throw "args should be array"
|
if (!is_array(args)) throw "args should be array"
|
||||||
args.push(4)
|
push(args, 4)
|
||||||
return length(args)
|
return length(args)
|
||||||
}
|
}
|
||||||
var result = proxy.test(1, 2, 3)
|
var result = proxy.test(1, 2, 3)
|
||||||
@@ -3135,7 +3102,7 @@ return {
|
|||||||
test_arrfor_with_index: function() {
|
test_arrfor_with_index: function() {
|
||||||
var arr = ["a", "b", "c"]
|
var arr = ["a", "b", "c"]
|
||||||
var indices = []
|
var indices = []
|
||||||
arrfor(arr, (x, i) => { indices.push(i) })
|
arrfor(arr, (x, i) => { push(indices, i) })
|
||||||
if (indices[0] != 0 || indices[2] != 2) throw "arrfor with index failed"
|
if (indices[0] != 0 || indices[2] != 2) throw "arrfor with index failed"
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -3148,7 +3115,7 @@ return {
|
|||||||
test_arrfor_mutation: function() {
|
test_arrfor_mutation: function() {
|
||||||
var arr = [1, 2, 3]
|
var arr = [1, 2, 3]
|
||||||
var results = []
|
var results = []
|
||||||
arrfor(arr, x => { results.push(x * 2) })
|
arrfor(arr, x => { push(results, x * 2) })
|
||||||
if (results[0] != 2 || results[1] != 4 || results[2] != 6) throw "arrfor mutation failed"
|
if (results[0] != 2 || results[1] != 4 || results[2] != 6) throw "arrfor mutation failed"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function deep_compare(expected, actual, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testarr = []
|
var testarr = []
|
||||||
for (var i = 0; i < 500; i++) { testarr.push(1) }
|
for (var i = 0; i < 500; i++) { push(testarr, 1) }
|
||||||
|
|
||||||
var testCases = [
|
var testCases = [
|
||||||
{ name: 'zero', input: 0 },
|
{ name: 'zero', input: 0 },
|
||||||
|
|||||||
16
toml.cm
16
toml.cm
@@ -119,7 +119,7 @@ function parse_key_path(str) {
|
|||||||
} else if (c == '.' && !in_quote) {
|
} else if (c == '.' && !in_quote) {
|
||||||
var piece = trim(current)
|
var piece = trim(current)
|
||||||
if (piece == null) piece = trim(current)
|
if (piece == null) piece = trim(current)
|
||||||
parts.push(parse_key(piece))
|
push(parts, parse_key(piece))
|
||||||
current = ''
|
current = ''
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ function parse_key_path(str) {
|
|||||||
|
|
||||||
var tail = trim(current)
|
var tail = trim(current)
|
||||||
if (tail == null) tail = trim(current)
|
if (tail == null) tail = trim(current)
|
||||||
if (length(tail) > 0) parts.push(parse_key(tail))
|
if (length(tail) > 0) push(parts, parse_key(tail))
|
||||||
|
|
||||||
return parts
|
return parts
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ function parse_array(str) {
|
|||||||
} else if (ch == ',' && !in_quotes) {
|
} else if (ch == ',' && !in_quotes) {
|
||||||
var piece = trim(current)
|
var piece = trim(current)
|
||||||
if (piece == null) piece = trim(current)
|
if (piece == null) piece = trim(current)
|
||||||
items.push(parse_value(piece))
|
push(items, parse_value(piece))
|
||||||
current = ''
|
current = ''
|
||||||
} else {
|
} else {
|
||||||
current += ch
|
current += ch
|
||||||
@@ -163,7 +163,7 @@ function parse_array(str) {
|
|||||||
|
|
||||||
var last = trim(current)
|
var last = trim(current)
|
||||||
if (last == null) last = trim(current)
|
if (last == null) last = trim(current)
|
||||||
if (last) items.push(parse_value(last))
|
if (last) push(items, parse_value(last))
|
||||||
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ function encode_toml(obj) {
|
|||||||
if (is_number(value)) return text(value)
|
if (is_number(value)) return text(value)
|
||||||
if (is_array(value)) {
|
if (is_array(value)) {
|
||||||
var items = []
|
var items = []
|
||||||
for (var i = 0; i < length(value); i++) items.push(encode_value(value[i]))
|
for (var i = 0; i < length(value); i++) push(items, encode_value(value[i]))
|
||||||
return '[' + text(items, ', ') + ']'
|
return '[' + text(items, ', ') + ']'
|
||||||
}
|
}
|
||||||
return text(value)
|
return text(value)
|
||||||
@@ -209,7 +209,7 @@ function encode_toml(obj) {
|
|||||||
for (var i = 0; i < length(keys); i++) {
|
for (var i = 0; i < length(keys); i++) {
|
||||||
var key = keys[i]
|
var key = keys[i]
|
||||||
var value = obj[key]
|
var value = obj[key]
|
||||||
if (!is_object(value)) result.push(quote_key(key) + ' = ' + encode_value(value))
|
if (!is_object(value)) push(result, quote_key(key) + ' = ' + encode_value(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second pass: encode nested objects
|
// Second pass: encode nested objects
|
||||||
@@ -222,14 +222,14 @@ function encode_toml(obj) {
|
|||||||
if (is_object(value)) {
|
if (is_object(value)) {
|
||||||
var quoted = quote_key(key)
|
var quoted = quote_key(key)
|
||||||
var section_path = path ? path + '.' + quoted : quoted
|
var section_path = path ? path + '.' + quoted : quoted
|
||||||
result.push('[' + section_path + ']')
|
push(result, '[' + section_path + ']')
|
||||||
|
|
||||||
// Direct properties
|
// Direct properties
|
||||||
var section_keys = array(value)
|
var section_keys = array(value)
|
||||||
for (var j = 0; j < length(section_keys); j++) {
|
for (var j = 0; j < length(section_keys); j++) {
|
||||||
var sk = section_keys[j]
|
var sk = section_keys[j]
|
||||||
var sv = value[sk]
|
var sv = value[sk]
|
||||||
if (!is_object(sv)) result.push(quote_key(sk) + ' = ' + encode_value(sv))
|
if (!is_object(sv)) push(result, quote_key(sk) + ' = ' + encode_value(sv))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nested sections
|
// Nested sections
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ var updated_packages = []
|
|||||||
if (target_pkg) {
|
if (target_pkg) {
|
||||||
var updated = update_and_fetch(target_pkg)
|
var updated = update_and_fetch(target_pkg)
|
||||||
if (updated) {
|
if (updated) {
|
||||||
updated_packages.push(updated)
|
push(updated_packages, updated)
|
||||||
log.console("Updated " + target_pkg + ".")
|
log.console("Updated " + target_pkg + ".")
|
||||||
} else {
|
} else {
|
||||||
log.console(target_pkg + " is up to date.")
|
log.console(target_pkg + " is up to date.")
|
||||||
@@ -116,7 +116,7 @@ if (target_pkg) {
|
|||||||
|
|
||||||
var updated = update_and_fetch(pkg)
|
var updated = update_and_fetch(pkg)
|
||||||
if (updated) {
|
if (updated) {
|
||||||
updated_packages.push(updated)
|
push(updated_packages, updated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
verify.ce
10
verify.ce
@@ -65,11 +65,11 @@ var warnings = []
|
|||||||
var checked = 0
|
var checked = 0
|
||||||
|
|
||||||
function add_error(msg) {
|
function add_error(msg) {
|
||||||
errors.push(msg)
|
push(errors, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_warning(msg) {
|
function add_warning(msg) {
|
||||||
warnings.push(msg)
|
push(warnings, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify a single package
|
// Verify a single package
|
||||||
@@ -212,12 +212,12 @@ if (scope == 'shop') {
|
|||||||
if (deep) {
|
if (deep) {
|
||||||
// Gather all dependencies
|
// Gather all dependencies
|
||||||
var all_deps = pkg.gather_dependencies(locator)
|
var all_deps = pkg.gather_dependencies(locator)
|
||||||
packages_to_verify.push(locator)
|
push(packages_to_verify, locator)
|
||||||
arrfor(all_deps, function(dep) {
|
arrfor(all_deps, function(dep) {
|
||||||
packages_to_verify.push(dep)
|
push(packages_to_verify, dep)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
packages_to_verify.push(locator)
|
push(packages_to_verify, locator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user