How to use the @glimmer/interfaces.ExpressionContext.Expression function in @glimmer/interfaces

To help you get started, we’ve selected a few @glimmer/interfaces examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / push-resolution.ts View on Github external
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];
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
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;
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder.ts View on Github external
}

    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
        ),
      ];
    }
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder.ts View on Github external
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];
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / template-compiler.ts View on Github external
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;
  }
}