Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case HighLevelResolutionOpcode.ResolveFree: {
throw new Error('Unimplemented HighLevelResolutionOpcode.ResolveFree');
}
case HighLevelResolutionOpcode.ResolveContextualFree: {
let { freeVar, context: expressionContext } = operation.op1;
if (context.meta.asPartial) {
let name = context.meta.upvars![freeVar];
concatExpressions(encoder, context, [op(Op.ResolveMaybeLocal, name)], constants);
break;
}
switch (expressionContext) {
case ExpressionContext.Expression: {
// in classic mode, this is always a this-fallback
let name = context.meta.upvars![freeVar];
concatExpressions(
encoder,
context,
[op(Op.GetVariable, 0), op(Op.GetProperty, name)],
constants
);
break;
}
case ExpressionContext.AppendSingleId: {
let resolver = context.syntax.program.resolverDelegate;
let name = context.meta.upvars![freeVar];
function mustacheContext(body: AST.Expression): ExpressionContext {
if (body.type === 'PathExpression') {
if (body.parts.length > 1 || body.data) {
return ExpressionContext.Expression;
} else {
return ExpressionContext.AppendSingleId;
}
} else {
return ExpressionContext.Expression;
}
}
}
case ExpressionKind.Call: {
let builtParams = buildParams(expr.params, symbols);
let builtHash = buildHash(expr.hash, symbols);
let builtExpr = buildPath(expr.path, ExpressionContext.CallHead, symbols);
return [Op.Call, 0, 0, builtExpr, builtParams, builtHash];
}
case ExpressionKind.HasBlock: {
return [
Op.HasBlock,
buildVar(
{ kind: VariableKind.Block, name: expr.name },
ExpressionContext.Expression,
symbols
),
];
}
case ExpressionKind.HasBlockParams: {
return [
Op.HasBlockParams,
buildVar(
{ kind: VariableKind.Block, name: expr.name },
ExpressionContext.Expression,
symbols
),
];
}
export function buildPath(
path: Path,
context: ExpressionContext,
symbols: Symbols
): Expressions.GetPath {
if (path.tail.length === 0) {
return [Op.GetPath, buildVar(path.variable, context, symbols), path.tail];
} else {
return [Op.GetPath, buildVar(path.variable, ExpressionContext.Expression, symbols), path.tail];
}
}
function mustacheContext(body: AST.Expression): ExpressionContext {
if (body.type === 'PathExpression') {
if (body.parts.length > 1 || body.data) {
return ExpressionContext.Expression;
} else {
return ExpressionContext.AppendSingleId;
}
} else {
return ExpressionContext.Expression;
}
}