|
@@ -165,7 +165,7 @@ let real_path = function
|
|
| ["flash"] , "Error" -> [], "Error"
|
|
| ["flash"] , "Error" -> [], "Error"
|
|
| ["flash"] , "Vector" -> ["__AS3__";"vec"], "Vector"
|
|
| ["flash"] , "Vector" -> ["__AS3__";"vec"], "Vector"
|
|
| path -> path
|
|
| path -> path
|
|
-
|
|
|
|
|
|
+
|
|
let type_path ctx path =
|
|
let type_path ctx path =
|
|
let pack, name = real_path path in
|
|
let pack, name = real_path path in
|
|
HMPath (pack,name)
|
|
HMPath (pack,name)
|
|
@@ -304,7 +304,7 @@ let property ctx p t =
|
|
(try
|
|
(try
|
|
let f = PMap.find p c.cl_fields in
|
|
let f = PMap.find p c.cl_fields in
|
|
ident p, Some (classify ctx (apply_params c.cl_types params f.cf_type)), false
|
|
ident p, Some (classify ctx (apply_params c.cl_types params f.cf_type)), false
|
|
- with Not_found ->
|
|
|
|
|
|
+ with Not_found ->
|
|
ident p, None, false)
|
|
ident p, None, false)
|
|
| _ ->
|
|
| _ ->
|
|
ident p, None, false
|
|
ident p, None, false
|
|
@@ -424,7 +424,7 @@ let gen_local_access ctx name p (forset : 'a) : 'a access =
|
|
if is_set forset then write ctx (HFindProp p);
|
|
if is_set forset then write ctx (HFindProp p);
|
|
VGlobal p
|
|
VGlobal p
|
|
|
|
|
|
-let get_local_register ctx name =
|
|
|
|
|
|
+let get_local_register ctx name =
|
|
match (try PMap.find name ctx.locals with Not_found -> LScope 0) with
|
|
match (try PMap.find name ctx.locals with Not_found -> LScope 0) with
|
|
| LReg r -> Some r
|
|
| LReg r -> Some r
|
|
| _ -> None
|
|
| _ -> None
|
|
@@ -540,7 +540,7 @@ let end_fun ctx args tret =
|
|
| None -> HVNone
|
|
| None -> HVNone
|
|
| Some c ->
|
|
| Some c ->
|
|
match c with
|
|
match c with
|
|
- | TInt i ->
|
|
|
|
|
|
+ | TInt i ->
|
|
(match classify ctx t with
|
|
(match classify ctx t with
|
|
| KUInt -> HVUInt i
|
|
| KUInt -> HVUInt i
|
|
| _ -> HVInt i)
|
|
| _ -> HVInt i)
|
|
@@ -753,7 +753,7 @@ let gen_access ctx e (forset : 'a) : 'a access =
|
|
| _ -> gen_expr ctx true e1);
|
|
| _ -> gen_expr ctx true e1);
|
|
(match k with
|
|
(match k with
|
|
| Some t -> VCast (id,t)
|
|
| Some t -> VCast (id,t)
|
|
- | None ->
|
|
|
|
|
|
+ | None ->
|
|
match follow e1.etype, follow e.etype with
|
|
match follow e1.etype, follow e.etype with
|
|
| _ , TFun _ when not ctx.for_call -> VCast(id,classify ctx e.etype)
|
|
| _ , TFun _ when not ctx.for_call -> VCast(id,classify ctx e.etype)
|
|
| TEnum _, _ -> VId id
|
|
| TEnum _, _ -> VId id
|
|
@@ -788,13 +788,13 @@ let gen_expr_twice ctx e =
|
|
| Some r ->
|
|
| Some r ->
|
|
write ctx (HReg r.rid);
|
|
write ctx (HReg r.rid);
|
|
write ctx (HReg r.rid);
|
|
write ctx (HReg r.rid);
|
|
- | None ->
|
|
|
|
|
|
+ | None ->
|
|
gen_expr ctx true e;
|
|
gen_expr ctx true e;
|
|
write ctx HDup)
|
|
write ctx HDup)
|
|
| TConst _ ->
|
|
| TConst _ ->
|
|
gen_expr ctx true e;
|
|
gen_expr ctx true e;
|
|
gen_expr ctx true e;
|
|
gen_expr ctx true e;
|
|
- | _ ->
|
|
|
|
|
|
+ | _ ->
|
|
gen_expr ctx true e;
|
|
gen_expr ctx true e;
|
|
write ctx HDup
|
|
write ctx HDup
|
|
|
|
|
|
@@ -925,7 +925,7 @@ let rec gen_expr_content ctx retval e =
|
|
write ctx (HArray 0)
|
|
write ctx (HArray 0)
|
|
| TNew (c,tl,pl) ->
|
|
| TNew (c,tl,pl) ->
|
|
let id = type_id ctx (TInst (c,tl)) in
|
|
let id = type_id ctx (TInst (c,tl)) in
|
|
- (match id with
|
|
|
|
|
|
+ (match id with
|
|
| HMParams _ ->
|
|
| HMParams _ ->
|
|
gen_type ctx id;
|
|
gen_type ctx id;
|
|
List.iter (gen_expr ctx true) pl;
|
|
List.iter (gen_expr ctx true) pl;
|
|
@@ -1074,7 +1074,7 @@ let rec gen_expr_content ctx retval e =
|
|
let t = classify ctx e.etype in
|
|
let t = classify ctx e.etype in
|
|
(try
|
|
(try
|
|
let t0 = classify ctx e0.etype in
|
|
let t0 = classify ctx e0.etype in
|
|
- (* generate optimized int switch *)
|
|
|
|
|
|
+ (* generate optimized int switch *)
|
|
if t0 <> KInt && t0 <> KUInt then raise Exit;
|
|
if t0 <> KInt && t0 <> KUInt then raise Exit;
|
|
let rec get_int e =
|
|
let rec get_int e =
|
|
match e.eexpr with
|
|
match e.eexpr with
|
|
@@ -1398,8 +1398,8 @@ and gen_unop ctx retval op flag e =
|
|
let acc_read, acc_write = gen_access_rw ctx e in
|
|
let acc_read, acc_write = gen_access_rw ctx e in
|
|
let op = (match k, incr with
|
|
let op = (match k, incr with
|
|
| KInt, true -> A3OIIncr
|
|
| KInt, true -> A3OIIncr
|
|
- | KInt, false -> A3OIDecr
|
|
|
|
- | _ , true -> A3OIncr
|
|
|
|
|
|
+ | KInt, false -> A3OIDecr
|
|
|
|
+ | _ , true -> A3OIncr
|
|
| _ , false -> A3ODecr
|
|
| _ , false -> A3ODecr
|
|
) in
|
|
) in
|
|
getvar ctx acc_read;
|
|
getvar ctx acc_read;
|
|
@@ -1417,7 +1417,7 @@ and gen_unop ctx retval op flag e =
|
|
setvar ctx acc_write (if retval then Some k else None)
|
|
setvar ctx acc_write (if retval then Some k else None)
|
|
|
|
|
|
and gen_binop ctx retval op e1 e2 t =
|
|
and gen_binop ctx retval op e1 e2 t =
|
|
- let write_op op =
|
|
|
|
|
|
+ let write_op op =
|
|
let iop = (match op with
|
|
let iop = (match op with
|
|
| OpAdd -> Some A3OIAdd
|
|
| OpAdd -> Some A3OIAdd
|
|
| OpSub -> Some A3OISub
|
|
| OpSub -> Some A3OISub
|
|
@@ -1746,7 +1746,7 @@ let generate_class ctx c =
|
|
| None -> acc
|
|
| None -> acc
|
|
| Some k ->
|
|
| Some k ->
|
|
{
|
|
{
|
|
- hlf_name = ident f.cf_name;
|
|
|
|
|
|
+ hlf_name = if c.cl_interface then HMName (f.cf_name, HNNamespace (match c.cl_path with [],n -> n | l,n -> String.concat ":" (l@[n]))) else ident f.cf_name;
|
|
hlf_slot = 0;
|
|
hlf_slot = 0;
|
|
hlf_kind = k;
|
|
hlf_kind = k;
|
|
hlf_metas = None;
|
|
hlf_metas = None;
|
|
@@ -1931,7 +1931,7 @@ let generate_type ctx t =
|
|
let hlc = generate_enum ctx e in
|
|
let hlc = generate_enum ctx e in
|
|
let init = begin_fun ctx [] t_void [ethis] false e.e_pos in
|
|
let init = begin_fun ctx [] t_void [ethis] false e.e_pos in
|
|
generate_enum_init ctx e hlc;
|
|
generate_enum_init ctx e hlc;
|
|
- write ctx HRetVoid;
|
|
|
|
|
|
+ write ctx HRetVoid;
|
|
Some (init(), {
|
|
Some (init(), {
|
|
hlf_name = type_path ctx e.e_path;
|
|
hlf_name = type_path ctx e.e_path;
|
|
hlf_slot = 0;
|
|
hlf_slot = 0;
|
|
@@ -1960,7 +1960,7 @@ let generate com =
|
|
try_scope_reg = None;
|
|
try_scope_reg = None;
|
|
for_call = false;
|
|
for_call = false;
|
|
} in
|
|
} in
|
|
- let classes = List.fold_left (fun acc t ->
|
|
|
|
|
|
+ let classes = List.fold_left (fun acc t ->
|
|
match generate_type ctx t with
|
|
match generate_type ctx t with
|
|
| None -> acc
|
|
| None -> acc
|
|
| Some (m,f) -> (t,m,f) :: acc
|
|
| Some (m,f) -> (t,m,f) :: acc
|