HTCast constructor

HTCast(
  1. HTEntity castee,
  2. HTClass klass,
  3. HTInterpreter interpreter, {
  4. List<HTType> typeArgs = const [],
})

Implementation

HTCast(HTEntity castee, this.klass, HTInterpreter interpreter,
    {List<HTType> typeArgs = const []})
    : valueType = HTNominalType(klass, typeArgs: typeArgs) {
  this.interpreter = interpreter;
  // final extended = <HTType>[];

  // HTClass? curSuper = klass;
  // var superClassType = HTType(klass.id, typeArgs: typeArgs);
  // while (curSuper != null) {
  // extended.add(superClassType);
  // curSuper = curSuper.superClass;
  // if (curSuper?.extendedType != null) {
  //   extended.add(curSuper!.extendedType!);
  // }
  // }
  if (castee.valueType?.isNotA(valueType) ?? true) {
    throw HTError.typeCast(interpreter.lexicon.stringify(castee.valueType),
        interpreter.lexicon.stringify(valueType));
  }

  if (castee is HTInstance) {
    object = castee;
  } else if (castee is HTCast) {
    object = castee.object;
  } else {
    throw HTError.castee(interpreter.localSymbol!);
  }
}