Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimmer/debug

Package Overview
Dependencies
Maintainers
13
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/debug - npm Package Compare versions

Comparing version 0.85.5 to 0.85.6

1676

dist/prod/index.js

@@ -1,1672 +0,10 @@

import { LOCAL_LOGGER, enumerate, decodeHandle, decodeImmediate } from '@glimmer/util';
import { Op, MachineOp, $v0, $t1, $t0, $s1, $s0, $sp, $fp, $ra, $pc } from '@glimmer/vm';
const LOCAL_SHOULD_LOG = (() => {
let location = typeof window !== 'undefined' && window.location;
if (location && /[&?]enable_local_should_log/u.test(window.location.search)) {
return true;
}
return false;
})();
/* This file is generated by build/debug.js */
function fillNulls(count) {
let arr = new Array(count);
for (let i = 0; i < count; i++) {
arr[i] = null;
}
return arr;
}
function opcodeMetadata(op, isMachine) {
let value = isMachine ? MACHINE_METADATA[op] : METADATA[op];
return value || null;
}
const METADATA = fillNulls(Op.Size);
const MACHINE_METADATA = fillNulls(MachineOp.Size);
MACHINE_METADATA[MachineOp.PushFrame] = {
name: 'PushFrame',
mnemonic: 'pushf',
before: null,
stackChange: 2,
ops: [],
operands: 0,
check: true
};
MACHINE_METADATA[MachineOp.PopFrame] = {
name: 'PopFrame',
mnemonic: 'popf',
before: null,
stackChange: -2,
ops: [],
operands: 0,
check: false
};
MACHINE_METADATA[MachineOp.InvokeVirtual] = {
name: 'InvokeVirtual',
mnemonic: 'vcall',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
MACHINE_METADATA[MachineOp.InvokeStatic] = {
name: 'InvokeStatic',
mnemonic: 'scall',
before: null,
stackChange: 0,
ops: [{
name: 'offset',
type: 'u32'
}],
operands: 1,
check: true
};
MACHINE_METADATA[MachineOp.Jump] = {
name: 'Jump',
mnemonic: 'goto',
before: null,
stackChange: 0,
ops: [{
name: 'to',
type: 'u32'
}],
operands: 1,
check: true
};
MACHINE_METADATA[MachineOp.Return] = {
name: 'Return',
mnemonic: 'ret',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: false
};
MACHINE_METADATA[MachineOp.ReturnTo] = {
name: 'ReturnTo',
mnemonic: 'setra',
before: null,
stackChange: 0,
ops: [{
name: 'offset',
type: 'i32'
}],
operands: 1,
check: true
};
METADATA[Op.Helper] = {
name: 'Helper',
mnemonic: 'ncall',
before: null,
stackChange: null,
ops: [{
name: 'helper',
type: 'handle'
}],
operands: 1,
check: true
};
METADATA[Op.DynamicHelper] = {
name: 'DynamicHelper',
mnemonic: 'dynamiccall',
before: null,
stackChange: null,
ops: [],
operands: 0,
check: true
};
METADATA[Op.SetNamedVariables] = {
name: 'SetNamedVariables',
mnemonic: 'vsargs',
before: null,
stackChange: 0,
ops: [{
name: 'register',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.SetBlocks] = {
name: 'SetBlocks',
mnemonic: 'vbblocks',
before: null,
stackChange: 0,
ops: [{
name: 'register',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.SetVariable] = {
name: 'SetVariable',
mnemonic: 'sbvar',
before: null,
stackChange: -1,
ops: [{
name: 'symbol',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.SetBlock] = {
name: 'SetBlock',
mnemonic: 'sblock',
before: null,
stackChange: -3,
ops: [{
name: 'symbol',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.GetVariable] = {
name: 'GetVariable',
mnemonic: 'symload',
before: null,
stackChange: 1,
ops: [{
name: 'symbol',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.GetProperty] = {
name: 'GetProperty',
mnemonic: 'getprop',
before: null,
stackChange: 0,
ops: [{
name: 'property',
type: 'str'
}],
operands: 1,
check: true
};
METADATA[Op.GetBlock] = {
name: 'GetBlock',
mnemonic: 'blockload',
before: null,
stackChange: 1,
ops: [{
name: 'block',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.SpreadBlock] = {
name: 'SpreadBlock',
mnemonic: 'blockspread',
before: null,
stackChange: 2,
ops: [],
operands: 0,
check: true
};
METADATA[Op.HasBlock] = {
name: 'HasBlock',
mnemonic: 'hasblockload',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.HasBlockParams] = {
name: 'HasBlockParams',
mnemonic: 'hasparamsload',
before: null,
stackChange: -2,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Concat] = {
name: 'Concat',
mnemonic: 'concat',
before: null,
stackChange: null,
ops: [{
name: 'count',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.IfInline] = {
name: 'IfInline',
mnemonic: 'ifinline',
before: null,
stackChange: -2,
ops: [{
name: 'count',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.Not] = {
name: 'Not',
mnemonic: 'not',
before: null,
stackChange: 0,
ops: [{
name: 'count',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.Constant] = {
name: 'Constant',
mnemonic: 'rconstload',
before: null,
stackChange: 1,
ops: [{
name: 'constant',
type: 'unknown'
}],
operands: 1,
check: true
};
METADATA[Op.ConstantReference] = {
name: 'ConstantReference',
mnemonic: 'rconstrefload',
before: null,
stackChange: 1,
ops: [{
name: 'constant',
type: 'unknown'
}],
operands: 1,
check: true
};
METADATA[Op.Primitive] = {
name: 'Primitive',
mnemonic: 'pconstload',
before: null,
stackChange: 1,
ops: [{
name: 'constant',
type: 'primitive'
}],
operands: 1,
check: true
};
METADATA[Op.PrimitiveReference] = {
name: 'PrimitiveReference',
mnemonic: 'ptoref',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.ReifyU32] = {
name: 'ReifyU32',
mnemonic: 'reifyload',
before: null,
stackChange: 1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Dup] = {
name: 'Dup',
mnemonic: 'dup',
before: null,
stackChange: 1,
ops: [{
name: 'register',
type: 'u32'
}, {
name: 'offset',
type: 'u32'
}],
operands: 2,
check: true
};
METADATA[Op.Pop] = {
name: 'Pop',
mnemonic: 'pop',
before: null,
stackChange: 0,
ops: [{
name: 'count',
type: 'u32'
}],
operands: 1,
check: false
};
METADATA[Op.Load] = {
name: 'Load',
mnemonic: 'put',
before: null,
stackChange: -1,
ops: [{
name: 'register',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.Fetch] = {
name: 'Fetch',
mnemonic: 'regload',
before: null,
stackChange: 1,
ops: [{
name: 'register',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.RootScope] = {
name: 'RootScope',
mnemonic: 'rscopepush',
before: null,
stackChange: 0,
ops: [{
name: 'symbols',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.VirtualRootScope] = {
name: 'VirtualRootScope',
mnemonic: 'vrscopepush',
before: null,
stackChange: 0,
ops: [{
name: 'register',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.ChildScope] = {
name: 'ChildScope',
mnemonic: 'cscopepush',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PopScope] = {
name: 'PopScope',
mnemonic: 'scopepop',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Text] = {
name: 'Text',
mnemonic: 'apnd_text',
before: null,
stackChange: 0,
ops: [{
name: 'contents',
type: 'str'
}],
operands: 1,
check: true
};
METADATA[Op.Comment] = {
name: 'Comment',
mnemonic: 'apnd_comment',
before: null,
stackChange: 0,
ops: [{
name: 'contents',
type: 'str'
}],
operands: 1,
check: true
};
METADATA[Op.AppendHTML] = {
name: 'AppendHTML',
mnemonic: 'apnd_dynhtml',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.AppendSafeHTML] = {
name: 'AppendSafeHTML',
mnemonic: 'apnd_dynshtml',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.AppendDocumentFragment] = {
name: 'AppendDocumentFragment',
mnemonic: 'apnd_dynfrag',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.AppendNode] = {
name: 'AppendNode',
mnemonic: 'apnd_dynnode',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.AppendText] = {
name: 'AppendText',
mnemonic: 'apnd_dyntext',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.OpenElement] = {
name: 'OpenElement',
mnemonic: 'apnd_tag',
before: null,
stackChange: 0,
ops: [{
name: 'tag',
type: 'str'
}],
operands: 1,
check: true
};
METADATA[Op.OpenDynamicElement] = {
name: 'OpenDynamicElement',
mnemonic: 'apnd_dyntag',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PushRemoteElement] = {
name: 'PushRemoteElement',
mnemonic: 'apnd_remotetag',
before: null,
stackChange: -3,
ops: [],
operands: 0,
check: true
};
METADATA[Op.StaticAttr] = {
name: 'StaticAttr',
mnemonic: 'apnd_attr',
before: null,
stackChange: 0,
ops: [{
name: 'name',
type: 'str'
}, {
name: 'value',
type: 'str'
}, {
name: 'namespace',
type: 'option-str'
}],
operands: 3,
check: true
};
METADATA[Op.DynamicAttr] = {
name: 'DynamicAttr',
mnemonic: 'apnd_dynattr',
before: null,
stackChange: -1,
ops: [{
name: 'name',
type: 'str'
}, {
name: 'trusting',
type: 'bool'
}, {
name: 'namespace',
type: 'option-str'
}],
operands: 3,
check: true
};
METADATA[Op.ComponentAttr] = {
name: 'ComponentAttr',
mnemonic: 'apnd_cattr',
before: null,
stackChange: -1,
ops: [{
name: 'name',
type: 'str'
}, {
name: 'trusting',
type: 'bool'
}, {
name: 'namespace',
type: 'option-str'
}],
operands: 3,
check: true
};
METADATA[Op.FlushElement] = {
name: 'FlushElement',
mnemonic: 'apnd_flushtag',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.CloseElement] = {
name: 'CloseElement',
mnemonic: 'apnd_closetag',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PopRemoteElement] = {
name: 'PopRemoteElement',
mnemonic: 'apnd_closeremotetag',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Modifier] = {
name: 'Modifier',
mnemonic: 'apnd_modifier',
before: null,
stackChange: -1,
ops: [{
name: 'helper',
type: 'handle'
}],
operands: 1,
check: true
};
METADATA[Op.BindDynamicScope] = {
name: 'BindDynamicScope',
mnemonic: 'setdynscope',
before: null,
stackChange: null,
ops: [{
name: 'names',
type: 'str-array'
}],
operands: 1,
check: true
};
METADATA[Op.PushDynamicScope] = {
name: 'PushDynamicScope',
mnemonic: 'dynscopepush',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PopDynamicScope] = {
name: 'PopDynamicScope',
mnemonic: 'dynscopepop',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.CompileBlock] = {
name: 'CompileBlock',
mnemonic: 'cmpblock',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PushBlockScope] = {
name: 'PushBlockScope',
mnemonic: 'scopeload',
before: null,
stackChange: 1,
ops: [{
name: 'scope',
type: 'scope'
}],
operands: 1,
check: true
};
METADATA[Op.PushSymbolTable] = {
name: 'PushSymbolTable',
mnemonic: 'dsymload',
before: null,
stackChange: 1,
ops: [{
name: 'table',
type: 'symbol-table'
}],
operands: 1,
check: true
};
METADATA[Op.InvokeYield] = {
name: 'InvokeYield',
mnemonic: 'invokeyield',
before: null,
stackChange: null,
ops: [],
operands: 0,
check: true
};
METADATA[Op.JumpIf] = {
name: 'JumpIf',
mnemonic: 'iftrue',
before: null,
stackChange: -1,
ops: [{
name: 'to',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.JumpUnless] = {
name: 'JumpUnless',
mnemonic: 'iffalse',
before: null,
stackChange: -1,
ops: [{
name: 'to',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.JumpEq] = {
name: 'JumpEq',
mnemonic: 'ifeq',
before: null,
stackChange: 0,
ops: [{
name: 'to',
type: 'i32'
}, {
name: 'comparison',
type: 'i32'
}],
operands: 2,
check: true
};
METADATA[Op.AssertSame] = {
name: 'AssertSame',
mnemonic: 'assert_eq',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Enter] = {
name: 'Enter',
mnemonic: 'blk_start',
before: null,
stackChange: 0,
ops: [{
name: 'args',
type: 'u32'
}],
operands: 1,
check: true
};
METADATA[Op.Exit] = {
name: 'Exit',
mnemonic: 'blk_end',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.ToBoolean] = {
name: 'ToBoolean',
mnemonic: 'anytobool',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.EnterList] = {
name: 'EnterList',
mnemonic: 'list_start',
before: null,
stackChange: null,
ops: [{
name: 'address',
type: 'u32'
}, {
name: 'address',
type: 'u32'
}],
operands: 2,
check: true
};
METADATA[Op.ExitList] = {
name: 'ExitList',
mnemonic: 'list_end',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Iterate] = {
name: 'Iterate',
mnemonic: 'iter',
before: null,
stackChange: 0,
ops: [{
name: 'end',
type: 'u32'
}],
operands: 1,
check: false
};
METADATA[Op.Main] = {
name: 'Main',
mnemonic: 'main',
before: null,
stackChange: -2,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.ContentType] = {
name: 'ContentType',
mnemonic: 'ctload',
before: null,
stackChange: 1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.DynamicContentType] = {
name: 'DynamicContentType',
mnemonic: 'dctload',
before: null,
stackChange: 1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.Curry] = {
name: 'Curry',
mnemonic: 'curry',
before: null,
stackChange: null,
ops: [{
name: 'type',
type: 'u32'
}, {
name: 'is-strict',
type: 'bool'
}],
operands: 2,
check: true
};
METADATA[Op.PushComponentDefinition] = {
name: 'PushComponentDefinition',
mnemonic: 'cmload',
before: null,
stackChange: 1,
ops: [{
name: 'spec',
type: 'handle'
}],
operands: 1,
check: true
};
METADATA[Op.PushDynamicComponentInstance] = {
name: 'PushDynamicComponentInstance',
mnemonic: 'dciload',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.ResolveDynamicComponent] = {
name: 'ResolveDynamicComponent',
mnemonic: 'cdload',
before: null,
stackChange: 0,
ops: [{
name: 'owner',
type: 'owner'
}],
operands: 1,
check: true
};
METADATA[Op.PushArgs] = {
name: 'PushArgs',
mnemonic: 'argsload',
before: null,
stackChange: null,
ops: [{
name: 'names',
type: 'str-array'
}, {
name: 'block-names',
type: 'str-array'
}, {
name: 'flags',
type: 'u32'
}],
operands: 3,
check: true
};
METADATA[Op.PushEmptyArgs] = {
name: 'PushEmptyArgs',
mnemonic: 'emptyargsload',
before: null,
stackChange: 1,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PopArgs] = {
name: 'PopArgs',
mnemonic: 'argspop',
before: null,
stackChange: null,
ops: [],
operands: 0,
check: true
};
METADATA[Op.PrepareArgs] = {
name: 'PrepareArgs',
mnemonic: 'argsprep',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: false
};
METADATA[Op.CaptureArgs] = {
name: 'CaptureArgs',
mnemonic: 'argscapture',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.CreateComponent] = {
name: 'CreateComponent',
mnemonic: 'comp_create',
before: null,
stackChange: 0,
ops: [{
name: 'flags',
type: 'u32'
}, {
name: 'state',
type: 'register'
}],
operands: 2,
check: true
};
METADATA[Op.RegisterComponentDestructor] = {
name: 'RegisterComponentDestructor',
mnemonic: 'comp_dest',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.PutComponentOperations] = {
name: 'PutComponentOperations',
mnemonic: 'comp_elops',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.GetComponentSelf] = {
name: 'GetComponentSelf',
mnemonic: 'comp_selfload',
before: null,
stackChange: 1,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.GetComponentTagName] = {
name: 'GetComponentTagName',
mnemonic: 'comp_tagload',
before: null,
stackChange: 1,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.GetComponentLayout] = {
name: 'GetComponentLayout',
mnemonic: 'comp_layoutload',
before: null,
stackChange: 2,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.BindEvalScope] = {
name: 'BindEvalScope',
mnemonic: 'eval_scope',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.SetupForEval] = {
name: 'SetupForEval',
mnemonic: 'eval_setup',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.PopulateLayout] = {
name: 'PopulateLayout',
mnemonic: 'comp_layoutput',
before: null,
stackChange: -2,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.InvokeComponentLayout] = {
name: 'InvokeComponentLayout',
mnemonic: 'comp_invokelayout',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.BeginComponentTransaction] = {
name: 'BeginComponentTransaction',
mnemonic: 'comp_begin',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.CommitComponentTransaction] = {
name: 'CommitComponentTransaction',
mnemonic: 'comp_commit',
before: null,
stackChange: 0,
ops: [],
operands: 0,
check: true
};
METADATA[Op.DidCreateElement] = {
name: 'DidCreateElement',
mnemonic: 'comp_created',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.DidRenderLayout] = {
name: 'DidRenderLayout',
mnemonic: 'comp_rendered',
before: null,
stackChange: 0,
ops: [{
name: 'state',
type: 'register'
}],
operands: 1,
check: true
};
METADATA[Op.ResolveMaybeLocal] = {
name: 'ResolveMaybeLocal',
mnemonic: 'eval_varload',
before: null,
stackChange: 1,
ops: [{
name: 'local',
type: 'str'
}],
operands: 1,
check: true
};
METADATA[Op.Debugger] = {
name: 'Debugger',
mnemonic: 'debugger',
before: null,
stackChange: 0,
ops: [{
name: 'symbols',
type: 'str-array'
}, {
name: 'debugInfo',
type: 'array'
}],
operands: 2,
check: true
};
function debugSlice(context, start, end) {
if (LOCAL_SHOULD_LOG) {
LOCAL_LOGGER.group(`%c${start}:${end}`, 'color: #999');
let heap = context.program.heap;
let opcode = context.program.createOp(heap);
let _size = 0;
for (let i = start; i < end; i = i + _size) {
opcode.offset = i;
let [name, params] = debug(context.program.constants, opcode, opcode.isMachine);
LOCAL_LOGGER.log(`${i}. ${logOpcode(name, params)}`);
_size = opcode.size;
}
opcode.offset = -_size;
LOCAL_LOGGER.groupEnd();
}
}
function logOpcode(type, params) {
if (LOCAL_SHOULD_LOG) {
let out = type;
if (params) {
let args = Object.keys(params).map(p => ` ${p}=${json(params[p])}`).join('');
out += args;
}
return `(${out})`;
}
}
function json(param) {
if (LOCAL_SHOULD_LOG) {
if (typeof param === 'function') {
return '<function>';
}
let string;
try {
string = JSON.stringify(param);
} catch (e) {
return '<object>';
}
if (string === undefined) {
return 'undefined';
}
let debug = JSON.parse(string);
if (typeof debug === 'object' && debug !== null && debug.GlimmerDebug !== undefined) {
return debug.GlimmerDebug;
}
return string;
}
}
function debug(c, op, isMachine) {
if (LOCAL_SHOULD_LOG) {
let metadata = opcodeMetadata(op.type, isMachine);
if (!metadata) {
throw new Error(`Missing Opcode Metadata for ${op}`);
}
let out = Object.create(null);
for (const [index, operand] of enumerate(metadata.ops)) {
let actualOperand = opcodeOperand(op, index);
switch (operand.type) {
case 'u32':
case 'i32':
case 'owner':
out[operand.name] = actualOperand;
break;
case 'handle':
out[operand.name] = c.getValue(actualOperand);
break;
case 'str':
case 'option-str':
case 'array':
out[operand.name] = c.getValue(actualOperand);
break;
case 'str-array':
out[operand.name] = c.getArray(actualOperand);
break;
case 'bool':
out[operand.name] = !!actualOperand;
break;
case 'primitive':
out[operand.name] = decodePrimitive(actualOperand, c);
break;
case 'register':
out[operand.name] = decodeRegister(actualOperand);
break;
case 'unknown':
out[operand.name] = c.getValue(actualOperand);
break;
case 'symbol-table':
case 'scope':
out[operand.name] = `<scope ${actualOperand}>`;
break;
default:
throw new Error(`Unexpected operand type ${operand.type} for debug output`);
import{LOCAL_LOGGER as e,enumerate as n,decodeHandle as t,decodeImmediate as a}from"@glimmer/util";import{Op as o,MachineOp as r,$v0 as c,$t1 as s,$t0 as p,$s1 as m,$s0 as l,$sp as i,$fp as u,$ra as h,$pc as d}from"@glimmer/vm";const f=!("undefined"==typeof window||!window.location||!/[&?]enable_local_should_log/u.test(window.location.search));function k(e){let n=new Array(e);for(let t=0;t<e;t++)n[t]=null;return n}function y(e,n){return(n?b[e]:g[e])||null}const g=k(o.Size),b=k(r.Size);function C(n,t,a){if(f){e.group(`%c${t}:${a}`,"color: #999");let o=n.program.heap,r=n.program.createOp(o),c=0;for(let o=t;o<a;o+=c){r.offset=o;let[t,a]=S(n.program.constants,r,r.isMachine);e.log(`${o}. ${v(t,a)}`),c=r.size}r.offset=-c,e.groupEnd()}}function v(e,n){if(f){let t=e;if(n){let e=Object.keys(n).map((e=>` ${e}=${function(e){if(f){if("function"==typeof e)return"<function>";let n;try{n=JSON.stringify(e)}catch(e){return"<object>"}if(void 0===n)return"undefined";let t=JSON.parse(n);return"object"==typeof t&&null!==t&&void 0!==t.GlimmerDebug?t.GlimmerDebug:n}}(n[e])}`)).join("");t+=e}return`(${t})`}}function S(e,t,a){if(f){let o=y(t.type,a);if(!o)throw new Error(`Missing Opcode Metadata for ${t}`);let r=Object.create(null);for(const[a,c]of n(o.ops)){let n=w(t,a);switch(c.type){case"u32":case"i32":case"owner":r[c.name]=n;break;case"handle":case"str":case"option-str":case"array":case"unknown":r[c.name]=e.getValue(n);break;case"str-array":r[c.name]=e.getArray(n);break;case"bool":r[c.name]=!!n;break;case"primitive":r[c.name]=x(n,e);break;case"register":r[c.name]=A(n);break;case"symbol-table":case"scope":r[c.name]=`<scope ${n}>`;break;default:throw new Error(`Unexpected operand type ${c.type} for debug output`)}}return[o.name,r]}}function w(e,n){switch(n){case 0:return e.op1;case 1:return e.op2;case 2:return e.op3;default:throw new Error("Unexpected operand index (must be 0-2)")}}function A(e){switch(e){case d:return"pc";case h:return"ra";case u:return"fp";case i:return"sp";case l:return"s0";case m:return"s1";case p:return"t0";case s:return"t1";case c:return"v0"}}function x(e,n){return e>=0?n.getValue(t(e)):a(e)}b[r.PushFrame]={name:"PushFrame",mnemonic:"pushf",before:null,stackChange:2,ops:[],operands:0,check:!0},b[r.PopFrame]={name:"PopFrame",mnemonic:"popf",before:null,stackChange:-2,ops:[],operands:0,check:!1},b[r.InvokeVirtual]={name:"InvokeVirtual",mnemonic:"vcall",before:null,stackChange:-1,ops:[],operands:0,check:!0},b[r.InvokeStatic]={name:"InvokeStatic",mnemonic:"scall",before:null,stackChange:0,ops:[{name:"offset",type:"u32"}],operands:1,check:!0},b[r.Jump]={name:"Jump",mnemonic:"goto",before:null,stackChange:0,ops:[{name:"to",type:"u32"}],operands:1,check:!0},b[r.Return]={name:"Return",mnemonic:"ret",before:null,stackChange:0,ops:[],operands:0,check:!1},b[r.ReturnTo]={name:"ReturnTo",mnemonic:"setra",before:null,stackChange:0,ops:[{name:"offset",type:"i32"}],operands:1,check:!0},g[o.Helper]={name:"Helper",mnemonic:"ncall",before:null,stackChange:null,ops:[{name:"helper",type:"handle"}],operands:1,check:!0},g[o.DynamicHelper]={name:"DynamicHelper",mnemonic:"dynamiccall",before:null,stackChange:null,ops:[],operands:0,check:!0},g[o.SetNamedVariables]={name:"SetNamedVariables",mnemonic:"vsargs",before:null,stackChange:0,ops:[{name:"register",type:"u32"}],operands:1,check:!0},g[o.SetBlocks]={name:"SetBlocks",mnemonic:"vbblocks",before:null,stackChange:0,ops:[{name:"register",type:"u32"}],operands:1,check:!0},g[o.SetVariable]={name:"SetVariable",mnemonic:"sbvar",before:null,stackChange:-1,ops:[{name:"symbol",type:"u32"}],operands:1,check:!0},g[o.SetBlock]={name:"SetBlock",mnemonic:"sblock",before:null,stackChange:-3,ops:[{name:"symbol",type:"u32"}],operands:1,check:!0},g[o.GetVariable]={name:"GetVariable",mnemonic:"symload",before:null,stackChange:1,ops:[{name:"symbol",type:"u32"}],operands:1,check:!0},g[o.GetProperty]={name:"GetProperty",mnemonic:"getprop",before:null,stackChange:0,ops:[{name:"property",type:"str"}],operands:1,check:!0},g[o.GetBlock]={name:"GetBlock",mnemonic:"blockload",before:null,stackChange:1,ops:[{name:"block",type:"u32"}],operands:1,check:!0},g[o.SpreadBlock]={name:"SpreadBlock",mnemonic:"blockspread",before:null,stackChange:2,ops:[],operands:0,check:!0},g[o.HasBlock]={name:"HasBlock",mnemonic:"hasblockload",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.HasBlockParams]={name:"HasBlockParams",mnemonic:"hasparamsload",before:null,stackChange:-2,ops:[],operands:0,check:!0},g[o.Concat]={name:"Concat",mnemonic:"concat",before:null,stackChange:null,ops:[{name:"count",type:"u32"}],operands:1,check:!0},g[o.IfInline]={name:"IfInline",mnemonic:"ifinline",before:null,stackChange:-2,ops:[{name:"count",type:"u32"}],operands:1,check:!0},g[o.Not]={name:"Not",mnemonic:"not",before:null,stackChange:0,ops:[{name:"count",type:"u32"}],operands:1,check:!0},g[o.Constant]={name:"Constant",mnemonic:"rconstload",before:null,stackChange:1,ops:[{name:"constant",type:"unknown"}],operands:1,check:!0},g[o.ConstantReference]={name:"ConstantReference",mnemonic:"rconstrefload",before:null,stackChange:1,ops:[{name:"constant",type:"unknown"}],operands:1,check:!0},g[o.Primitive]={name:"Primitive",mnemonic:"pconstload",before:null,stackChange:1,ops:[{name:"constant",type:"primitive"}],operands:1,check:!0},g[o.PrimitiveReference]={name:"PrimitiveReference",mnemonic:"ptoref",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.ReifyU32]={name:"ReifyU32",mnemonic:"reifyload",before:null,stackChange:1,ops:[],operands:0,check:!0},g[o.Dup]={name:"Dup",mnemonic:"dup",before:null,stackChange:1,ops:[{name:"register",type:"u32"},{name:"offset",type:"u32"}],operands:2,check:!0},g[o.Pop]={name:"Pop",mnemonic:"pop",before:null,stackChange:0,ops:[{name:"count",type:"u32"}],operands:1,check:!1},g[o.Load]={name:"Load",mnemonic:"put",before:null,stackChange:-1,ops:[{name:"register",type:"u32"}],operands:1,check:!0},g[o.Fetch]={name:"Fetch",mnemonic:"regload",before:null,stackChange:1,ops:[{name:"register",type:"u32"}],operands:1,check:!0},g[o.RootScope]={name:"RootScope",mnemonic:"rscopepush",before:null,stackChange:0,ops:[{name:"symbols",type:"u32"}],operands:1,check:!0},g[o.VirtualRootScope]={name:"VirtualRootScope",mnemonic:"vrscopepush",before:null,stackChange:0,ops:[{name:"register",type:"u32"}],operands:1,check:!0},g[o.ChildScope]={name:"ChildScope",mnemonic:"cscopepush",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.PopScope]={name:"PopScope",mnemonic:"scopepop",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.Text]={name:"Text",mnemonic:"apnd_text",before:null,stackChange:0,ops:[{name:"contents",type:"str"}],operands:1,check:!0},g[o.Comment]={name:"Comment",mnemonic:"apnd_comment",before:null,stackChange:0,ops:[{name:"contents",type:"str"}],operands:1,check:!0},g[o.AppendHTML]={name:"AppendHTML",mnemonic:"apnd_dynhtml",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.AppendSafeHTML]={name:"AppendSafeHTML",mnemonic:"apnd_dynshtml",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.AppendDocumentFragment]={name:"AppendDocumentFragment",mnemonic:"apnd_dynfrag",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.AppendNode]={name:"AppendNode",mnemonic:"apnd_dynnode",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.AppendText]={name:"AppendText",mnemonic:"apnd_dyntext",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.OpenElement]={name:"OpenElement",mnemonic:"apnd_tag",before:null,stackChange:0,ops:[{name:"tag",type:"str"}],operands:1,check:!0},g[o.OpenDynamicElement]={name:"OpenDynamicElement",mnemonic:"apnd_dyntag",before:null,stackChange:-1,ops:[],operands:0,check:!0},g[o.PushRemoteElement]={name:"PushRemoteElement",mnemonic:"apnd_remotetag",before:null,stackChange:-3,ops:[],operands:0,check:!0},g[o.StaticAttr]={name:"StaticAttr",mnemonic:"apnd_attr",before:null,stackChange:0,ops:[{name:"name",type:"str"},{name:"value",type:"str"},{name:"namespace",type:"option-str"}],operands:3,check:!0},g[o.DynamicAttr]={name:"DynamicAttr",mnemonic:"apnd_dynattr",before:null,stackChange:-1,ops:[{name:"name",type:"str"},{name:"trusting",type:"bool"},{name:"namespace",type:"option-str"}],operands:3,check:!0},g[o.ComponentAttr]={name:"ComponentAttr",mnemonic:"apnd_cattr",before:null,stackChange:-1,ops:[{name:"name",type:"str"},{name:"trusting",type:"bool"},{name:"namespace",type:"option-str"}],operands:3,check:!0},g[o.FlushElement]={name:"FlushElement",mnemonic:"apnd_flushtag",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.CloseElement]={name:"CloseElement",mnemonic:"apnd_closetag",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.PopRemoteElement]={name:"PopRemoteElement",mnemonic:"apnd_closeremotetag",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.Modifier]={name:"Modifier",mnemonic:"apnd_modifier",before:null,stackChange:-1,ops:[{name:"helper",type:"handle"}],operands:1,check:!0},g[o.BindDynamicScope]={name:"BindDynamicScope",mnemonic:"setdynscope",before:null,stackChange:null,ops:[{name:"names",type:"str-array"}],operands:1,check:!0},g[o.PushDynamicScope]={name:"PushDynamicScope",mnemonic:"dynscopepush",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.PopDynamicScope]={name:"PopDynamicScope",mnemonic:"dynscopepop",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.CompileBlock]={name:"CompileBlock",mnemonic:"cmpblock",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.PushBlockScope]={name:"PushBlockScope",mnemonic:"scopeload",before:null,stackChange:1,ops:[{name:"scope",type:"scope"}],operands:1,check:!0},g[o.PushSymbolTable]={name:"PushSymbolTable",mnemonic:"dsymload",before:null,stackChange:1,ops:[{name:"table",type:"symbol-table"}],operands:1,check:!0},g[o.InvokeYield]={name:"InvokeYield",mnemonic:"invokeyield",before:null,stackChange:null,ops:[],operands:0,check:!0},g[o.JumpIf]={name:"JumpIf",mnemonic:"iftrue",before:null,stackChange:-1,ops:[{name:"to",type:"u32"}],operands:1,check:!0},g[o.JumpUnless]={name:"JumpUnless",mnemonic:"iffalse",before:null,stackChange:-1,ops:[{name:"to",type:"u32"}],operands:1,check:!0},g[o.JumpEq]={name:"JumpEq",mnemonic:"ifeq",before:null,stackChange:0,ops:[{name:"to",type:"i32"},{name:"comparison",type:"i32"}],operands:2,check:!0},g[o.AssertSame]={name:"AssertSame",mnemonic:"assert_eq",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.Enter]={name:"Enter",mnemonic:"blk_start",before:null,stackChange:0,ops:[{name:"args",type:"u32"}],operands:1,check:!0},g[o.Exit]={name:"Exit",mnemonic:"blk_end",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.ToBoolean]={name:"ToBoolean",mnemonic:"anytobool",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.EnterList]={name:"EnterList",mnemonic:"list_start",before:null,stackChange:null,ops:[{name:"address",type:"u32"},{name:"address",type:"u32"}],operands:2,check:!0},g[o.ExitList]={name:"ExitList",mnemonic:"list_end",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.Iterate]={name:"Iterate",mnemonic:"iter",before:null,stackChange:0,ops:[{name:"end",type:"u32"}],operands:1,check:!1},g[o.Main]={name:"Main",mnemonic:"main",before:null,stackChange:-2,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.ContentType]={name:"ContentType",mnemonic:"ctload",before:null,stackChange:1,ops:[],operands:0,check:!0},g[o.DynamicContentType]={name:"DynamicContentType",mnemonic:"dctload",before:null,stackChange:1,ops:[],operands:0,check:!0},g[o.Curry]={name:"Curry",mnemonic:"curry",before:null,stackChange:null,ops:[{name:"type",type:"u32"},{name:"is-strict",type:"bool"}],operands:2,check:!0},g[o.PushComponentDefinition]={name:"PushComponentDefinition",mnemonic:"cmload",before:null,stackChange:1,ops:[{name:"spec",type:"handle"}],operands:1,check:!0},g[o.PushDynamicComponentInstance]={name:"PushDynamicComponentInstance",mnemonic:"dciload",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.ResolveDynamicComponent]={name:"ResolveDynamicComponent",mnemonic:"cdload",before:null,stackChange:0,ops:[{name:"owner",type:"owner"}],operands:1,check:!0},g[o.PushArgs]={name:"PushArgs",mnemonic:"argsload",before:null,stackChange:null,ops:[{name:"names",type:"str-array"},{name:"block-names",type:"str-array"},{name:"flags",type:"u32"}],operands:3,check:!0},g[o.PushEmptyArgs]={name:"PushEmptyArgs",mnemonic:"emptyargsload",before:null,stackChange:1,ops:[],operands:0,check:!0},g[o.PopArgs]={name:"PopArgs",mnemonic:"argspop",before:null,stackChange:null,ops:[],operands:0,check:!0},g[o.PrepareArgs]={name:"PrepareArgs",mnemonic:"argsprep",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!1},g[o.CaptureArgs]={name:"CaptureArgs",mnemonic:"argscapture",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.CreateComponent]={name:"CreateComponent",mnemonic:"comp_create",before:null,stackChange:0,ops:[{name:"flags",type:"u32"},{name:"state",type:"register"}],operands:2,check:!0},g[o.RegisterComponentDestructor]={name:"RegisterComponentDestructor",mnemonic:"comp_dest",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.PutComponentOperations]={name:"PutComponentOperations",mnemonic:"comp_elops",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.GetComponentSelf]={name:"GetComponentSelf",mnemonic:"comp_selfload",before:null,stackChange:1,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.GetComponentTagName]={name:"GetComponentTagName",mnemonic:"comp_tagload",before:null,stackChange:1,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.GetComponentLayout]={name:"GetComponentLayout",mnemonic:"comp_layoutload",before:null,stackChange:2,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.BindEvalScope]={name:"BindEvalScope",mnemonic:"eval_scope",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.SetupForEval]={name:"SetupForEval",mnemonic:"eval_setup",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.PopulateLayout]={name:"PopulateLayout",mnemonic:"comp_layoutput",before:null,stackChange:-2,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.InvokeComponentLayout]={name:"InvokeComponentLayout",mnemonic:"comp_invokelayout",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.BeginComponentTransaction]={name:"BeginComponentTransaction",mnemonic:"comp_begin",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.CommitComponentTransaction]={name:"CommitComponentTransaction",mnemonic:"comp_commit",before:null,stackChange:0,ops:[],operands:0,check:!0},g[o.DidCreateElement]={name:"DidCreateElement",mnemonic:"comp_created",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.DidRenderLayout]={name:"DidRenderLayout",mnemonic:"comp_rendered",before:null,stackChange:0,ops:[{name:"state",type:"register"}],operands:1,check:!0},g[o.ResolveMaybeLocal]={name:"ResolveMaybeLocal",mnemonic:"eval_varload",before:null,stackChange:1,ops:[{name:"local",type:"str"}],operands:1,check:!0},g[o.Debugger]={name:"Debugger",mnemonic:"debugger",before:null,stackChange:0,ops:[{name:"symbols",type:"str-array"},{name:"debugInfo",type:"array"}],operands:2,check:!0};const $=["u32","i32","owner","handle","str","option-str","array","str-array","bool","primitive","register","unknown","symbol-table","scope"];function E(e,n){let t;if(void 0===n.format)throw new Error(`Missing format in ${JSON.stringify(n)}`);t=Array.isArray(n.format)?n.format[0]:n.format;let a=Array.isArray(n.format)?function(e){if(!Array.isArray(e))throw new Error(`Expected operands array, got ${JSON.stringify(e)}`);return e.map(D)}(n.format.slice(1)):[];return{name:t,mnemonic:e,before:null,stackChange:P(n["operand-stack"]),ops:a,operands:a.length,check:!0!==n.skip}}function P(e){if(void 0===e)return 0;let n=e[0],t=e[1];return _(n)||_(t)?null:t.length-n.length}function _(e){if(!Array.isArray(e))throw new Error(`Unexpected stack entry: ${JSON.stringify(e)}`);return e.some((e=>"..."===e.slice(-3)))}function D(e){let[n,t]=e.split(":");if(a=t,-1!==$.indexOf(a))return{name:n,type:t};throw new Error(`Expected operand, found ${JSON.stringify(e)}`);var a}function T(e){return{machine:O(e.machine),syscall:O(e.syscall)}}function O(e){let n=Object.create(null);for(const[t,a]of Object.entries(e))n[t]=E(t,a);return n}function R(e,n,t,a){let o,r=[`export enum ${e} {`];Object.values(n).forEach(((e,n)=>{r.push(` ${e.name} = ${t+n},`),o=n})),r.push(` Size = ${o+t+1},`),r.push("}");let c,s=r.join("\n");return c=a?j`
export function is${e}(value: number): value is ${e} {
return value >= ${t} && value <= ${a};
}
}
return [metadata.name, out];
}
return undefined;
}
function opcodeOperand(opcode, index) {
switch (index) {
case 0:
return opcode.op1;
case 1:
return opcode.op2;
case 2:
return opcode.op3;
default:
throw new Error(`Unexpected operand index (must be 0-2)`);
}
}
function decodeRegister(register) {
switch (register) {
case $pc:
return 'pc';
case $ra:
return 'ra';
case $fp:
return 'fp';
case $sp:
return 'sp';
case $s0:
return 's0';
case $s1:
return 's1';
case $t0:
return 't0';
case $t1:
return 't1';
case $v0:
return 'v0';
}
}
function decodePrimitive(primitive, constants) {
if (primitive >= 0) {
return constants.getValue(decodeHandle(primitive));
}
return decodeImmediate(primitive);
}
// TODO: How do these map onto constant and machine types?
const OPERAND_TYPES = ['u32', 'i32', 'owner', 'handle', 'str', 'option-str', 'array', 'str-array', 'bool', 'primitive', 'register', 'unknown', 'symbol-table', 'scope'];
function isOperandType(s) {
return OPERAND_TYPES.indexOf(s) !== -1;
}
function normalize(key, input) {
let name;
if (input.format === undefined) {
throw new Error(`Missing format in ${JSON.stringify(input)}`);
}
if (Array.isArray(input.format)) {
name = input.format[0];
} else {
name = input.format;
}
let ops = Array.isArray(input.format) ? operands(input.format.slice(1)) : [];
return {
name,
mnemonic: key,
before: null,
stackChange: stackChange(input['operand-stack']),
ops,
operands: ops.length,
check: input.skip === true ? false : true
};
}
function stackChange(stack) {
if (stack === undefined) {
return 0;
}
let before = stack[0];
let after = stack[1];
if (hasRest(before) || hasRest(after)) {
return null;
}
return after.length - before.length;
}
function hasRest(input) {
if (!Array.isArray(input)) {
throw new Error(`Unexpected stack entry: ${JSON.stringify(input)}`);
}
return input.some(s => s.slice(-3) === '...');
}
function operands(input) {
if (!Array.isArray(input)) {
throw new Error(`Expected operands array, got ${JSON.stringify(input)}`);
}
return input.map(op);
}
function op(input) {
let [name, type] = input.split(':');
if (isOperandType(type)) {
return {
name,
type
};
} else {
throw new Error(`Expected operand, found ${JSON.stringify(input)}`);
}
}
function normalizeAll(parsed) {
let machine = normalizeParsed(parsed.machine);
let syscall = normalizeParsed(parsed.syscall);
return {
machine,
syscall
};
}
function normalizeParsed(parsed) {
let out = Object.create(null);
for (const [key, value] of Object.entries(parsed)) {
out[key] = normalize(key, value);
}
return out;
}
function buildEnum(name, parsed, offset, max) {
let e = [`export enum ${name} {`];
let last;
Object.values(parsed).forEach((value, i) => {
e.push(` ${value.name} = ${offset + i},`);
last = i;
});
e.push(` Size = ${last + offset + 1},`);
e.push('}');
let enumString = e.join('\n');
let predicate;
if (max) {
predicate = strip`
export function is${name}(value: number): value is ${name} {
return value >= ${offset} && value <= ${max};
`:j`
export function is${e}(value: number): value is ${e} {
return value >= ${t};
}
`;
} else {
predicate = strip`
export function is${name}(value: number): value is ${name} {
return value >= ${offset};
}
`;
}
return {
enumString,
predicate
};
}
function strip(strings) {
let out = '';
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
for (let i = 0; i < strings.length; i++) {
let string = strings[i];
let dynamic = args[i] !== undefined ? String(args[i]) : '';
out += `${string}${dynamic}`;
}
// eslint-disable-next-line regexp/no-super-linear-backtracking
out = /^\s*?\n?([\s\S]*?)\s*$/u.exec(out)[1];
let min = 9007199254740991; // Number.MAX_SAFE_INTEGER isn't available on IE11
for (let line of out.split('\n')) {
let leading = /^\s*/u.exec(line)[0].length;
min = Math.min(min, leading);
}
let stripped = '';
for (let line of out.split('\n')) {
stripped += line.slice(min) + '\n';
}
return stripped;
}
const META_KIND = ['METADATA', 'MACHINE_METADATA'];
function buildSingleMeta(kind, all, key) {
let e = kind === 'MACHINE_METADATA' ? 'MachineOp' : 'Op';
return `${kind}[${e}.${all[key].name}] = ${stringify(all[key], 0)};`;
}
function stringify(o, pad) {
if (typeof o !== 'object' || o === null) {
if (typeof o === 'string') {
return `'${o}'`;
}
return JSON.stringify(o);
}
if (Array.isArray(o)) {
return `[${o.map(v => stringify(v, pad)).join(', ')}]`;
}
let out = ['{'];
for (let key of Object.keys(o)) {
out.push(`${' '.repeat(pad + 2)}${key}: ${stringify(o[key], pad + 2)},`);
}
out.push(`${' '.repeat(pad)}}`);
return out.join('\n');
}
function buildMetas(kind, all) {
let out = [];
for (let key of Object.keys(all)) {
out.push(buildSingleMeta(kind, all, key));
}
return out.join('\n\n');
}
function wrap(checker) {
class Wrapped {
validate(value) {
return checker().validate(value);
}
expected() {
return checker().expected();
}
}
return new Wrapped();
}
class TypeofChecker {
constructor(expectedType) {
this.expectedType = expectedType;
}
validate(value) {
return typeof value === this.expectedType;
}
expected() {
return `typeof ${this.expectedType}`;
}
}
class PrimitiveChecker {
validate(value) {
return typeof value !== 'string' || typeof value === 'number' || typeof value === 'string' || value === undefined || value === null;
}
expected() {
return `a primitive`;
}
}
class NullChecker {
validate(value) {
return value === null;
}
expected() {
return `null`;
}
}
class InstanceofChecker {
constructor(Class) {
this.Class = Class;
}
validate(value) {
return value ? value instanceof this.Class : false;
}
expected() {
return `an instance of ${this.Class.name}`;
}
}
class OptionChecker {
constructor(checker, emptyValue) {
this.checker = checker;
this.emptyValue = emptyValue;
}
validate(value) {
if (value === this.emptyValue) return true;
return this.checker.validate(value);
}
expected() {
return `${this.checker.expected()} or null`;
}
}
class MaybeChecker {
constructor(checker) {
this.checker = checker;
}
validate(value) {
if (value === null || value === undefined) return true;
return this.checker.validate(value);
}
expected() {
return `${this.checker.expected()} or null or undefined`;
}
}
class OrChecker {
constructor(left, right) {
this.left = left;
this.right = right;
}
validate(value) {
return this.left.validate(value) || this.right.validate(value);
}
expected() {
return `${this.left.expected()} or ${this.right.expected()}`;
}
}
class ExactValueChecker {
constructor(value, desc) {
this.value = value;
this.desc = desc;
}
validate(obj) {
return obj === this.value;
}
expected() {
return this.desc;
}
}
class PropertyChecker {
constructor(checkers) {
this.checkers = checkers;
}
validate(obj) {
if (typeof obj !== 'object') return false;
if (obj === null || obj === undefined) return false;
return Object.entries(this.checkers).every(_ref => {
let [k, checker] = _ref;
return k in obj ? checker.validate(obj[k]) : false;
});
}
expected() {
let pairs = Object.entries(this.checkers).map(_ref2 => {
let [k, checker] = _ref2;
return `${k}: ${checker.expected()}`;
});
return `{ ${pairs.join(',')} }`;
}
}
class ArrayChecker {
constructor(checker) {
this.checker = checker;
}
validate(obj) {
if (obj === null || obj === undefined) return false;
if (!Array.isArray(obj)) return false;
return obj.every(item => this.checker.validate(item));
}
expected() {
return `Array<${this.checker.expected()}>`;
}
}
class DictChecker {
constructor(checker) {
this.checker = checker;
}
validate(value) {
let isDict = typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === null;
if (!isDict) return false;
let {
checker
} = this;
for (let key in value) {
if (!checker.validate(value[key])) {
return false;
}
}
return true;
}
expected() {
return `a primitive`;
}
}
class OpaqueChecker {
type;
validate(_obj) {
return true;
}
expected() {
return `any`;
}
}
class ObjectChecker {
validate(obj) {
return typeof obj === 'function' || typeof obj === 'object' && obj !== null;
}
expected() {
return `an object or function (valid WeakMap key)`;
}
}
class SafeStringChecker {
validate(value) {
return typeof value === 'object' && value !== null && typeof value.toHTML === 'function';
}
expected() {
return `SafeString`;
}
}
function CheckInstanceof(Class) {
return new InstanceofChecker(Class);
}
function CheckOption(checker) {
return new OptionChecker(checker, null);
}
function CheckMaybe(checker) {
return new MaybeChecker(checker);
}
function CheckInterface(obj) {
return new PropertyChecker(obj);
}
function CheckArray(obj) {
return new ArrayChecker(obj);
}
function CheckDict(obj) {
return new DictChecker(obj);
}
function defaultMessage(value, expected) {
return `Got ${value}, expected:\n${expected}`;
}
function check(value, checker) {
let message = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultMessage;
if (typeof checker === 'function') {
checker(value);
return value;
}
if (checker.validate(value)) {
return value;
} else {
throw new Error(message(value, checker.expected()));
}
}
let size = 0;
function recordStackSize(sp) {
size = sp;
}
function expectStackChange(stack, expected, name) {
let actual = stack.sp - size;
if (actual === expected) return;
throw new Error(`Expected stack to change by ${expected}, but it changed by ${actual} in ${name}`);
}
const CheckPrimitive = new PrimitiveChecker();
const CheckFunction = new TypeofChecker('function');
const CheckNumber = new TypeofChecker('number');
const CheckBoolean = new TypeofChecker('boolean');
const CheckHandle = CheckNumber;
const CheckString = new TypeofChecker('string');
const CheckNull = new NullChecker();
const CheckUnknown = new OpaqueChecker();
const CheckSafeString = new SafeStringChecker();
const CheckObject = new ObjectChecker();
function CheckOr(left, right) {
return new OrChecker(left, right);
}
function CheckValue(value) {
let desc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(value);
return new ExactValueChecker(value, desc);
}
const CheckBlockSymbolTable = CheckInterface({
parameters: CheckArray(CheckNumber)
});
const CheckProgramSymbolTable = CheckInterface({
hasEval: CheckBoolean,
symbols: CheckArray(CheckString)
});
const CheckElement = CheckInterface({
nodeType: CheckValue(1),
tagName: CheckString,
nextSibling: CheckUnknown
});
const CheckDocumentFragment = CheckInterface({
nodeType: CheckValue(11),
nextSibling: CheckUnknown
});
const CheckNode = CheckInterface({
nodeType: CheckNumber,
nextSibling: CheckUnknown
});
export { CheckArray, CheckBlockSymbolTable, CheckBoolean, CheckDict, CheckDocumentFragment, CheckElement, CheckFunction, CheckHandle, CheckInstanceof, CheckInterface, CheckMaybe, CheckNode, CheckNull, CheckNumber, CheckObject, CheckOption, CheckOr, CheckPrimitive, CheckProgramSymbolTable, CheckSafeString, CheckString, CheckUnknown, CheckValue, META_KIND, OPERAND_TYPES, buildEnum, buildMetas, buildSingleMeta, check, debug, debugSlice, expectStackChange, logOpcode, normalize, normalizeAll, normalizeParsed, opcodeMetadata, recordStackSize, strip, wrap };
`,{enumString:s,predicate:c}}function j(e){let n="";for(var t=arguments.length,a=new Array(t>1?t-1:0),o=1;o<t;o++)a[o-1]=arguments[o];for(let t=0;t<e.length;t++){n+=`${e[t]}${void 0!==a[t]?String(a[t]):""}`}n=/^\s*?\n?([\s\S]*?)\s*$/u.exec(n)[1];let r=9007199254740991;for(let e of n.split("\n")){let n=/^\s*/u.exec(e)[0].length;r=Math.min(r,n)}let c="";for(let e of n.split("\n"))c+=e.slice(r)+"\n";return c}const B=["METADATA","MACHINE_METADATA"];function M(e,n,t){return`${e}[${"MACHINE_METADATA"===e?"MachineOp":"Op"}.${n[t].name}] = ${I(n[t],0)};`}function I(e,n){if("object"!=typeof e||null===e)return"string"==typeof e?`'${e}'`:JSON.stringify(e);if(Array.isArray(e))return`[${e.map((e=>I(e,n))).join(", ")}]`;let t=["{"];for(let a of Object.keys(e))t.push(`${" ".repeat(n+2)}${a}: ${I(e[a],n+2)},`);return t.push(`${" ".repeat(n)}}`),t.join("\n")}function L(e,n){let t=[];for(let a of Object.keys(n))t.push(M(e,n,a));return t.join("\n\n")}function N(e){return new class{validate(n){return e().validate(n)}expected(){return e().expected()}}}class G{constructor(e){this.expectedType=e}validate(e){return typeof e===this.expectedType}expected(){return`typeof ${this.expectedType}`}}class H{constructor(e){this.Class=e}validate(e){return!!e&&e instanceof this.Class}expected(){return`an instance of ${this.Class.name}`}}class J{constructor(e,n){this.checker=e,this.emptyValue=n}validate(e){return e===this.emptyValue||this.checker.validate(e)}expected(){return`${this.checker.expected()} or null`}}class V{constructor(e){this.checker=e}validate(e){return null==e||this.checker.validate(e)}expected(){return`${this.checker.expected()} or null or undefined`}}class F{constructor(e,n){this.left=e,this.right=n}validate(e){return this.left.validate(e)||this.right.validate(e)}expected(){return`${this.left.expected()} or ${this.right.expected()}`}}class U{constructor(e,n){this.value=e,this.desc=n}validate(e){return e===this.value}expected(){return this.desc}}class q{constructor(e){this.checkers=e}validate(e){return"object"==typeof e&&(null!=e&&Object.entries(this.checkers).every((n=>{let[t,a]=n;return t in e&&a.validate(e[t])})))}expected(){return`{ ${Object.entries(this.checkers).map((e=>{let[n,t]=e;return`${n}: ${t.expected()}`})).join(",")} }`}}class z{constructor(e){this.checker=e}validate(e){return null!=e&&(!!Array.isArray(e)&&e.every((e=>this.checker.validate(e))))}expected(){return`Array<${this.checker.expected()}>`}}class Y{constructor(e){this.checker=e}validate(e){if(!("object"==typeof e&&null!==e&&null===Object.getPrototypeOf(e)))return!1;let{checker:n}=this;for(let t in e)if(!n.validate(e[t]))return!1;return!0}expected(){return"a primitive"}}function W(e){return new H(e)}function K(e){return new J(e,null)}function Q(e){return new V(e)}function X(e){return new q(e)}function Z(e){return new z(e)}function ee(e){return new Y(e)}function ne(e,n){return`Got ${e}, expected:\n${n}`}function te(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ne;if("function"==typeof n)return n(e),e;if(n.validate(e))return e;throw new Error(t(e,n.expected()))}let ae=0;function oe(e){ae=e}function re(e,n,t){let a=e.sp-ae;if(a!==n)throw new Error(`Expected stack to change by ${n}, but it changed by ${a} in ${t}`)}const ce=new class{validate(e){return"string"!=typeof e||"number"==typeof e||"string"==typeof e||null==e}expected(){return"a primitive"}},se=new G("function"),pe=new G("number"),me=new G("boolean"),le=pe,ie=new G("string"),ue=new class{validate(e){return null===e}expected(){return"null"}},he=new class{type;validate(e){return!0}expected(){return"any"}},de=new class{validate(e){return"object"==typeof e&&null!==e&&"function"==typeof e.toHTML}expected(){return"SafeString"}},fe=new class{validate(e){return"function"==typeof e||"object"==typeof e&&null!==e}expected(){return"an object or function (valid WeakMap key)"}};function ke(e,n){return new F(e,n)}function ye(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(e);return new U(e,n)}const ge=X({parameters:Z(pe)}),be=X({hasEval:me,symbols:Z(ie)}),Ce=X({nodeType:ye(1),tagName:ie,nextSibling:he}),ve=X({nodeType:ye(11),nextSibling:he}),Se=X({nodeType:pe,nextSibling:he});export{Z as CheckArray,ge as CheckBlockSymbolTable,me as CheckBoolean,ee as CheckDict,ve as CheckDocumentFragment,Ce as CheckElement,se as CheckFunction,le as CheckHandle,W as CheckInstanceof,X as CheckInterface,Q as CheckMaybe,Se as CheckNode,ue as CheckNull,pe as CheckNumber,fe as CheckObject,K as CheckOption,ke as CheckOr,ce as CheckPrimitive,be as CheckProgramSymbolTable,de as CheckSafeString,ie as CheckString,he as CheckUnknown,ye as CheckValue,B as META_KIND,$ as OPERAND_TYPES,R as buildEnum,L as buildMetas,M as buildSingleMeta,te as check,S as debug,C as debugSlice,re as expectStackChange,v as logOpcode,E as normalize,T as normalizeAll,O as normalizeParsed,y as opcodeMetadata,oe as recordStackSize,j as strip,N as wrap};
//# sourceMappingURL=index.js.map

10

package.json
{
"name": "@glimmer/debug",
"type": "module",
"version": "0.85.5",
"version": "0.85.6",
"repository": "https://github.com/glimmerjs/glimmer-vm/tree/master/packages/@glimmer/debug",

@@ -24,5 +24,5 @@ "main": "dist/prod/index.js",

"dependencies": {
"@glimmer/interfaces": "^0.85.5",
"@glimmer/util": "^0.85.5",
"@glimmer/vm": "^0.85.5"
"@glimmer/interfaces": "^0.85.6",
"@glimmer/util": "^0.85.6",
"@glimmer/vm": "^0.85.6"
},

@@ -34,3 +34,3 @@ "devDependencies": {

"publint": "^0.2.5",
"@glimmer/local-debug-flags": "^0.85.5",
"@glimmer/local-debug-flags": "^0.85.6",
"@glimmer-workspace/build-support": "^1.0.0"

@@ -37,0 +37,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc