MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / unifiedExec

Method unifiedExec

tools/common/_hyperscript.iife.js:2124–2181  ·  view source on GitHub ↗
(command, ctx)

Source from the content-addressed store, hash-verified

2122 // Core execution engine
2123 // =================================================================
2124 unifiedExec(command, ctx) {
2125 while (true) {
2126 try {
2127 var next = this.unifiedEval(command, ctx);
2128 } catch (e) {
2129 if (ctx.meta.handlingFinally) {
2130 console.error(" Exception in finally block: ", e);
2131 next = _Runtime.HALT;
2132 } else {
2133 this.registerHyperTrace(ctx, e);
2134 if (ctx.meta.errorHandler && !ctx.meta.handlingError) {
2135 ctx.meta.handlingError = true;
2136 ctx.locals[ctx.meta.errorSymbol] = e;
2137 command = ctx.meta.errorHandler;
2138 continue;
2139 } else {
2140 ctx.meta.currentException = e;
2141 next = _Runtime.HALT;
2142 }
2143 }
2144 }
2145 if (next == null) {
2146 throw new Error("Command " + (command.type || "unknown") + " did not return a next element to execute");
2147 } else if (next.then) {
2148 next.then((resolvedNext) => {
2149 this.unifiedExec(resolvedNext, ctx);
2150 }).catch((reason) => {
2151 this.unifiedExec({
2152 resolve: function() {
2153 throw reason;
2154 }
2155 }, ctx);
2156 });
2157 return;
2158 } else if (next === _Runtime.HALT) {
2159 if (ctx.meta.finallyHandler && !ctx.meta.handlingFinally) {
2160 ctx.meta.handlingFinally = true;
2161 command = ctx.meta.finallyHandler;
2162 } else {
2163 if (ctx.meta.onHalt) {
2164 ctx.meta.onHalt();
2165 }
2166 if (ctx.meta.currentException) {
2167 if (ctx.meta.reject) {
2168 ctx.meta.reject(ctx.meta.currentException);
2169 return;
2170 } else {
2171 throw ctx.meta.currentException;
2172 }
2173 } else {
2174 return;
2175 }
2176 }
2177 } else {
2178 command = next;
2179 }
2180 }
2181 }

Callers 1

executeMethod · 0.45

Calls 2

unifiedEvalMethod · 0.95
registerHyperTraceMethod · 0.95

Tested by

no test coverage detected