blob: 4f14d3dc3e60665b48c2b53a4d29fa29993e3907 [file] [log] [blame]
library;
import self as self;
import "dart:core" as core;
class MapLike<K extends core::Object* = dynamic, V extends core::Object* = dynamic> extends core::Object {
final field core::Map<self::MapLike::K*, self::MapLike::V*>* _map = <self::MapLike::K*, self::MapLike::V*>{};
synthetic constructor •() self::MapLike<self::MapLike::K*, self::MapLike::V*>*
: super core::Object::•()
;
method get(core::Object* key) self::MapLike::V*
return this.{self::MapLike::_map}.{core::Map::[]}(key);
method put(generic-covariant-impl self::MapLike::K* key, generic-covariant-impl self::MapLike::V* value) self::MapLike::V*
return let final core::Map<self::MapLike::K*, self::MapLike::V*>* #t1 = this.{self::MapLike::_map} in let final self::MapLike::K* #t2 = key in let final self::MapLike::V* #t3 = value in let final void #t4 = #t1.{core::Map::[]=}(#t2, #t3) in #t3;
}
extension Extension<K extends core::Object* = dynamic, V extends core::Object* = dynamic> on self::MapLike<K*, V*>* {
operator [] = self::Extension|[];
operator []= = self::Extension|[]=;
}
static method Extension|[]<K extends core::Object* = dynamic, V extends core::Object* = dynamic>(final self::MapLike<self::Extension|[]::K*, self::Extension|[]::V*>* #this, core::Object* key) → self::Extension|[]::V*
return #this.{self::MapLike::get}(key);
static method Extension|[]=<K extends core::Object* = dynamic, V extends core::Object* = dynamic>(final self::MapLike<self::Extension|[]=::K*, self::Extension|[]=::V*>* #this, self::Extension|[]=::K* key, self::Extension|[]=::V* value) → void
return #this.{self::MapLike::put}(key, value);
static method main() dynamic {
self::MapLike<core::int*, core::String*>* map1 = new self::MapLike::•<core::int*, core::String*>();
self::expect(null, self::Extension|[]<core::int*, core::String*>(map1, 0));
map1.{self::MapLike::put}(0, "0");
self::expect("0", self::Extension|[]<core::int*, core::String*>(map1, 0));
self::expect(null, self::Extension|[]<core::int*, core::String*>(map1, 1));
self::Extension|[]=<core::int*, core::String*>(map1, 1, "1");
self::expect("1", self::Extension|[]<core::int*, core::String*>(map1, 1));
self::expect("2", let final self::MapLike<core::int*, core::String*>* #t5 = map1 in let final core::int* #t6 = 1 in let final core::String* #t7 = "2" in let final void #t8 = self::Extension|[]=<core::int*, core::String*>(#t5, #t6, #t7) in #t7);
self::expect("2", self::Extension|[]<core::int*, core::String*>(map1, 1));
let final self::MapLike<core::int*, core::String*>* #t9 = map1 in let final core::int* #t10 = 1 in self::Extension|[]<core::int*, core::String*>(#t9, #t10).{core::String::==}(null) ?{core::String*} self::Extension|[]=<core::int*, core::String*>(#t9, #t10, "3") : null;
self::expect("2", self::Extension|[]<core::int*, core::String*>(map1, 1));
self::expect("2", let final self::MapLike<core::int*, core::String*>* #t11 = map1 in let final core::int* #t12 = 1 in let final core::String* #t13 = self::Extension|[]<core::int*, core::String*>(#t11, #t12) in #t13.{core::String::==}(null) ?{core::String*} let final core::String* #t14 = "4" in let final void #t15 = self::Extension|[]=<core::int*, core::String*>(#t11, #t12, #t14) in #t14 : #t13);
self::expect("2", self::Extension|[]<core::int*, core::String*>(map1, 1));
let final self::MapLike<core::int*, core::String*>* #t16 = map1 in let final core::int* #t17 = 2 in self::Extension|[]<core::int*, core::String*>(#t16, #t17).{core::String::==}(null) ?{core::String*} self::Extension|[]=<core::int*, core::String*>(#t16, #t17, "2") : null;
self::expect("2", self::Extension|[]<core::int*, core::String*>(map1, 2));
self::expect("3", let final self::MapLike<core::int*, core::String*>* #t18 = map1 in let final core::int* #t19 = 3 in let final core::String* #t20 = self::Extension|[]<core::int*, core::String*>(#t18, #t19) in #t20.{core::String::==}(null) ?{core::String*} let final core::String* #t21 = "3" in let final void #t22 = self::Extension|[]=<core::int*, core::String*>(#t18, #t19, #t21) in #t21 : #t20);
self::expect("3", self::Extension|[]<core::int*, core::String*>(map1, 3));
self::MapLike<core::int*, core::int*>* map2 = new self::MapLike::•<core::int*, core::int*>();
self::expect(1, let final self::MapLike<core::int*, core::int*>* #t23 = map2 in let final core::int* #t24 = 0 in let final core::int* #t25 = 1 in let final void #t26 = self::Extension|[]=<core::int*, core::int*>(#t23, #t24, #t25) in #t25);
self::expect(3, let final self::MapLike<core::int*, core::int*>* #t27 = map2 in let final core::int* #t28 = 0 in let final core::int* #t29 = self::Extension|[]<core::int*, core::int*>(#t27, #t28).{core::num::+}(2) in let final void #t30 = self::Extension|[]=<core::int*, core::int*>(#t27, #t28, #t29) in #t29);
self::expect(5, let final self::MapLike<core::int*, core::int*>* #t31 = map2 in let final core::int* #t32 = 0 in let final core::int* #t33 = self::Extension|[]<core::int*, core::int*>(#t31, #t32).{core::num::+}(2) in let final void #t34 = self::Extension|[]=<core::int*, core::int*>(#t31, #t32, #t33) in #t33);
self::expect(5, let final self::MapLike<core::int*, core::int*>* #t35 = map2 in let final core::int* #t36 = 0 in let final core::int* #t37 = self::Extension|[]<core::int*, core::int*>(#t35, #t36) in let final void #t38 = self::Extension|[]=<core::int*, core::int*>(#t35, #t36, #t37.{core::num::+}(1)) in #t37);
self::expect(6, self::Extension|[]<core::int*, core::int*>(map2, 0));
self::expect(5, let final self::MapLike<core::int*, core::int*>* #t39 = map2 in let final core::int* #t40 = 0 in let final core::int* #t41 = self::Extension|[]<core::int*, core::int*>(#t39, #t40).{core::num::-}(1) in let final void #t42 = self::Extension|[]=<core::int*, core::int*>(#t39, #t40, #t41) in #t41);
self::expect(5, self::Extension|[]<core::int*, core::int*>(map2, 0));
}
static method expect(dynamic expected, dynamic actual) dynamic {
if(!expected.{core::Object::==}(actual)) {
throw "Mismatch: expected=${expected}, actual=${actual}";
}
}