本文整理匯總了TypeScript中@glimmer/util.unreachable函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript unreachable函數的具體用法?TypeScript unreachable怎麽用?TypeScript unreachable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了unreachable函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: RootReference
export function valueToRef<T = Opaque>(value: T, bound = true): VersionedPathReference<T> {
if (isObject(value)) {
// root of interop with ember objects
return bound ? new RootReference(value) : new UnboundReference(value);
} else if (isFunction(value)) {
// ember doesn't do observing with functions
return new UnboundReference(value);
} else if (isPrimitive(value)) {
return PrimitiveReference.create(value);
} else if (DEBUG) {
let type = typeof value;
let output: Option<string>;
try {
output = String(value);
} catch (e) {
output = null;
}
if (output) {
throw unreachable(`[BUG] Unexpected ${type} (${output})`);
} else {
throw unreachable(`[BUG] Unexpected ${type}`);
}
} else {
throw unreachable();
}
}
示例2: debug
export function debug(c: DebugConstants, op: Op, ...operands: number[]): [string, object] {
let metadata = METADATA[op];
if (!metadata) {
throw unreachable(`Missing Opcode Metadata for ${op}`);
}
let out = dict<Opaque>();
metadata.ops.forEach((operand, index) => {
let op = operands[index];
switch (operand.type) {
case 'i32':
case 'symbol':
case 'block':
out[operand.name] = op;
break;
case 'handle':
out[operand.name] = c.resolveHandle(op);
break;
case 'str':
out[operand.name] = c.getString(op);
break;
case 'option-str':
out[operand.name] = op ? c.getString(op) : null;
break;
case 'str-array':
out[operand.name] = c.getStringArray(op);
break;
case 'array':
out[operand.name] = c.getArray(op);
break;
case 'bool':
out[operand.name] = !!op;
break;
case 'primitive':
out[operand.name] = decodePrimitive(op, c);
break;
case 'register':
out[operand.name] = Register[op];
break;
case 'table':
out[operand.name] = c.getSymbolTable(op);
break;
case 'serializable':
out[operand.name] = c.getSerializable(op);
break;
case 'lazy-constant':
out[operand.name] = (c as Recast<DebugConstants, LazyDebugConstants>).getOther(op);
break;
}
});
return [metadata.name, out];
}
示例3: decodePrimitive
function decodePrimitive(primitive: number, constants: DebugConstants): Primitive {
let flag = primitive & 7; // 111
let value = primitive >> 3;
switch (flag) {
case PrimitiveType.NUMBER:
return value;
case PrimitiveType.FLOAT:
return constants.getFloat(value);
case PrimitiveType.STRING:
return constants.getString(value);
case PrimitiveType.BOOLEAN_OR_VOID:
switch (value) {
case 0: return false;
case 1: return true;
case 2: return null;
case 3: return undefined;
}
default:
throw unreachable();
}
}
示例4: debug
export function debug(c: DebugConstants, op: Op, op1: number, op2: number, op3: number): [string, object] {
if (DEBUG) {
switch (op) {
case Op.Bug: throw unreachable();
case Op.Helper: return ['Helper', { helper: c.resolveHandle(op1) }];
case Op.SetVariable: return ['SetVariable', { symbol: op1 }];
case Op.SetBlock: return ['SetBlock', { symbol: op1 }];
case Op.GetVariable: return ['GetVariable', { symbol: op1 }];
case Op.GetProperty: return ['GetProperty', { key: op1 }];
case Op.GetBlock: return ['GetBlock', { symbol: op1 }];
case Op.HasBlock: return ['HasBlock', { block: op1 }];
case Op.HasBlockParams: return ['HasBlockParams', { block: op1 }];
case Op.Concat: return ['Concat', { size: op1 }];
case Op.Constant: return ['Constant', { value: op1 }];
case Op.Primitive: return ['Primitive', { primitive: op1 }];
case Op.PrimitiveReference: return ['PrimitiveReference', {}];
case Op.Dup: return ['Dup', { register: Register[op1], offset: op2 }];
case Op.Pop: return ['Pop', { count: op1 }];
case Op.Load: return ['Load', { register: Register[op1] }];
case Op.Fetch: return ['Fetch', { register: Register[op1] }];
/// PRELUDE & EXIT
case Op.RootScope: return ['RootScope', { symbols: op1, bindCallerScope: !!op2 }];
case Op.ChildScope: return ['ChildScope', {}];
case Op.PopScope: return ['PopScope', {}];
case Op.Return: return ['Return', {}];
case Op.ReturnTo: return ['ReturnTo', { offset: op1 }];
/// HTML
case Op.Text: return ['Text', { text: c.getString(op1) }];
case Op.Comment: return ['Comment', { comment: c.getString(op1) }];
case Op.DynamicContent: return ['DynamicContent', { trusting: !!op1 }];
case Op.OpenElement: return ['OpenElement', { tag: c.getString(op1) }];
case Op.OpenElementWithOperations: return ['OpenElementWithOperations', { tag: c.getString(op1) }];
case Op.OpenDynamicElement: return ['OpenDynamicElement', {}];
case Op.StaticAttr: return ['StaticAttr', { name: c.getString(op1), value: c.getString(op2), namespace: op3 ? c.getString(op3) : null }];
case Op.DynamicAttr: return ['DynamicAttr', { name: c.getString(op1), trusting: !!op2, namespace: op3 ? c.getString(op3) : null }];
case Op.ComponentAttr: return ['ComponentAttr', { name: c.getString(op1), trusting: !!op2, namespace: op3 ? c.getString(op3) : null }];
case Op.FlushElement: return ['FlushElement', {}];
case Op.CloseElement: return ['CloseElement', {}];
/// MODIFIER
case Op.Modifier: return ['Modifier', {}];
/// WORMHOLE
case Op.PushRemoteElement: return ['PushRemoteElement', {}];
case Op.PopRemoteElement: return ['PopRemoteElement', {}];
/// DYNAMIC SCOPE
case Op.BindDynamicScope: return ['BindDynamicScope', {}];
case Op.PushDynamicScope: return ['PushDynamicScope', {}];
case Op.PopDynamicScope: return ['PopDynamicScope', {}];
/// VM
case Op.PushSymbolTable: return ['PushSymbolTable', { table: c.getSymbolTable(op1) }];
case Op.PushScope: return ['PushScope', {}];
case Op.CompileBlock: return ['CompileBlock', {}];
case Op.InvokeVirtual: return ['InvokeVirtual', {}];
case Op.InvokeStatic: return ['InvokeStatic', { handle: op1 }];
case Op.InvokeYield: return ['InvokeYield', {}];
case Op.Jump: return ['Jump', { to: op1 }];
case Op.JumpIf: return ['JumpIf', { to: op1 }];
case Op.JumpUnless: return ['JumpUnless', { to: op1 }];
case Op.PushFrame: return ['PushFrame', {}];
case Op.PopFrame: return ['PopFrame', {}];
case Op.Enter: return ['Enter', { args: op1 }];
case Op.Exit: return ['Exit', {}];
case Op.ToBoolean: return ['ToBoolean', {}];
/// LISTS
case Op.EnterList: return ['EnterList', { start: op1 }];
case Op.ExitList: return ['ExitList', {}];
case Op.PutIterator: return ['PutIterator', {}];
case Op.Iterate: return ['Iterate', { end: op1 }];
/// COMPONENTS
case Op.IsComponent: return ['IsComponent', {}];
case Op.CurryComponent: return ['CurryComponent', { meta: c.getSerializable(op1) }];
case Op.PushComponentSpec: return ['PushComponentSpec', { definition: c.resolveHandle(op1) }];
case Op.PushDynamicComponentManager: return ['PushDynamicComponentManager', { meta: c.getSerializable(op1) }];
case Op.PushArgs: return ['PushArgs', { names: c.getStringArray(op1), positionals: op2, synthetic: !!op3 }];
case Op.PrepareArgs: return ['PrepareArgs', { state: Register[op1] }];
case Op.CreateComponent: return ['CreateComponent', { flags: op1, state: Register[op2] }];
case Op.RegisterComponentDestructor: return ['RegisterComponentDestructor', {}];
case Op.PutComponentOperations: return ['PutComponentOperations', {}];
case Op.GetComponentSelf: return ['GetComponentSelf', { state: Register[op1] }];
case Op.GetComponentTagName: return ['GetComponentTagName', { state: Register[op1] }];
case Op.GetComponentLayout: return ['GetComponentLayout', { state: Register[op1] }];
case Op.InvokeComponentLayout: return ['InvokeComponentLayout', {}];
case Op.BeginComponentTransaction: return ['BeginComponentTransaction', {}];
case Op.CommitComponentTransaction: return ['CommitComponentTransaction', {}];
case Op.DidCreateElement: return ['DidCreateElement', { state: Register[op1] }];
case Op.DidRenderLayout: return ['DidRenderLayout', {}];
/// PARTIALS
case Op.InvokePartial: return ['InvokePartial', { templateMeta: c.getSerializable(op1), symbols: c.getStringArray(op2), evalInfo: c.getArray(op3) }];
case Op.ResolveMaybeLocal: return ['ResolveMaybeLocal', { name: c.getString(op1)} ];
/// DEBUGGER
//.........這裏部分代碼省略.........
示例5: unreachable
inputMacro = () => {
throw unreachable();
};
示例6: unreachable
transformInputTypeSyntax = () => {
throw unreachable();
};
示例7: unreachable
textAreaMacro = () => {
throw unreachable();
};