$ function

Expr $(
  1. Object e
)

Convert a Dart value to an Expr.

This supports the following types:

Implementation

Expr $(Object e) {
  if (e is Expr) {
    return e;
  } else if (e is bool) {
    return e ? currentContext.trueExpr : currentContext.falseExpr;
  } else if (e is int) {
    return intFrom(e);
  } else if (e is BigInt) {
    return intBig(e);
  } else if (e is Rat) {
    return rat(e);
  } else if (e is double) {
    return float64(e);
  } else if (e is String) {
    return str(e);
  } else if (e is Enum) {
    final m = _declaredEnums[currentContext];
    if (m != null && m.containsKey(e.runtimeType)) {
      return m[e.runtimeType]!.$2.constants[Sym(e.name)]!;
    } else {
      throw ArgumentError.value(
        e,
        'e',
        'not declared, try using declareEnumValues',
      );
    }
  }
  throw ArgumentError.value(e, 'e', 'cant be converted to Expr');
}