Skip to content

Commit

Permalink
[cs] fix -D erase-generics again (now behave exactly like the Java ve…
Browse files Browse the repository at this point in the history
…rsion)
  • Loading branch information
nadako committed Mar 5, 2015
1 parent 193a670 commit 259b756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions gencs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,7 @@ let configure gen =
let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" Ast.null_pos [] in

let rcf_static_insert, rcf_static_remove =
if Common.defined gen.gcon Define.EraseGenerics then begin
if erase_generics then begin
let get_specialized_postfix t = match t with
| TAbstract({a_path = [],("Float" | "Int" as name)}, _) -> name
| TAnon _ | TDynamic _ -> "Dynamic"
Expand Down Expand Up @@ -2800,7 +2800,10 @@ let configure gen =
rcf_on_call_field
(fun hash hash_array length -> { hash with eexpr = TCall(rcf_static_find, [hash; hash_array; length]); etype=basic.tint })
(fun hash -> { hash with eexpr = TCall(rcf_static_lookup, [hash]); etype = gen.gcon.basic.tstring })
(fun hash_array length pos value -> { value with eexpr = TCall(rcf_static_insert value.etype, [hash_array; length; pos; value]); etype = gen.gcon.basic.tvoid })
(fun hash_array length pos value ->
let ecall = mk (TCall(rcf_static_insert value.etype, [hash_array; length; pos; value])) (if erase_generics then hash_array.etype else basic.tvoid) hash_array.epos in
if erase_generics then { ecall with eexpr = TBinop(OpAssign, hash_array, ecall) } else ecall
)
(fun hash_array length pos ->
let t = gen.gclasses.nativearray_type hash_array.etype in
{ hash_array with eexpr = TCall(rcf_static_remove t, [hash_array; length; pos]); etype = gen.gcon.basic.tvoid }
Expand Down
9 changes: 5 additions & 4 deletions std/cs/internal/FieldLookup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ package cs.internal;
}

@:extern
static inline function __insert<T>(a:cs.Ref<cs.NativeArray<T>>, length:Int, pos:Int, x:T)
static inline function __insert<T>(a:cs.NativeArray<T>, length:Int, pos:Int, x:T):cs.NativeArray<T>
{
var capacity = a.Length;
if (pos == length)
Expand Down Expand Up @@ -228,10 +228,11 @@ package cs.internal;
}
}
a[pos] = x;
return a;
}

static function insertInt(a:cs.Ref<cs.NativeArray<Int>>, length:Int, pos:Int, x:Int) __insert(a, length, pos, x);
static function insertFloat(a:cs.Ref<cs.NativeArray<Float>>, length:Int, pos:Int, x:Float) __insert(a, length, pos, x);
static function insertDynamic(a:cs.Ref<cs.NativeArray<Dynamic>>, length:Int, pos:Int, x:Dynamic) __insert(a, length, pos, x);
static function insertInt(a:cs.NativeArray<Int>, length:Int, pos:Int, x:Int):cs.NativeArray<Int> return __insert(a, length, pos, x);
static function insertFloat(a:cs.NativeArray<Float>, length:Int, pos:Int, x:Float):cs.NativeArray<Float> return __insert(a, length, pos, x);
static function insertDynamic(a:cs.NativeArray<Dynamic>, length:Int, pos:Int, x:Dynamic):cs.NativeArray<Dynamic> return __insert(a, length, pos, x);
#end
}

0 comments on commit 259b756

Please sign in to comment.