MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / handle_cmd

Function handle_cmd

examples/js/repl.js:1290–1331  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

1288 }
1289
1290 function handle_cmd(expr) {
1291 var colorstate, cmd;
1292
1293 if (expr === null) {
1294 expr = "";
1295 return;
1296 }
1297 if (expr === "?") {
1298 help();
1299 return;
1300 }
1301 cmd = extract_directive(expr);
1302 if (cmd.length > 0) {
1303 if (!handle_directive(cmd, expr))
1304 return;
1305 expr = expr.substring(cmd.length + 1);
1306 }
1307 if (expr === "")
1308 return;
1309
1310 if (mexpr)
1311 expr = mexpr + '\n' + expr;
1312 colorstate = colorize_js(expr);
1313 pstate = colorstate[0];
1314 level = colorstate[1];
1315 if (pstate) {
1316 mexpr = expr;
1317 return;
1318 }
1319 mexpr = "";
1320
1321 if (has_bignum) {
1322 BigFloatEnv.setPrec(eval_and_print.bind(null, expr),
1323 prec, expBits);
1324 } else {
1325 eval_and_print(expr);
1326 }
1327 level = 0;
1328
1329 /* run the garbage collector after each command */
1330 std.gc();
1331 }
1332
1333 function colorize_js(str) {
1334 var i, c, start, n = str.length;

Callers 1

readline_handle_cmdFunction · 0.85

Calls 6

helpFunction · 0.85
extract_directiveFunction · 0.85
handle_directiveFunction · 0.85
colorize_jsFunction · 0.85
eval_and_printFunction · 0.85
bindMethod · 0.80

Tested by

no test coverage detected