from static method

ASTType from(
  1. dynamic o, [
  2. VMContext? context
])

Implementation

static ASTType from(dynamic o, [VMContext? context]) {
  if (o == null) return ASTTypeNull.instance;

  if (o is ASTType) {
    return o;
  }

  if (o is ASTValue) {
    return o.type;
  }

  if (o is ASTTypedVariable) {
    return o.type;
  }

  if (o is ASTExpressionLiteral) {
    return ASTType.from(o.value, context);
  }

  if (o is ASTTypedNode) {
    var resolved = o.resolveType(context ?? VMContext.getCurrent());
    if (resolved is ASTType) {
      return resolved;
    } else {
      return ASTTypeDynamic.instance;
    }
  }

  return fromNativeValue(o);
}