Ignore:
Timestamp:
Jan 19, 2011, 6:23:27 PM (9 years ago)
Author:
campbell
Message:

Port memory spaces changes to latest prototype compiler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.3/8051-memoryspaces-branch/cparser/StructByValue.ml

    r453 r460  
    3939      if is_composite_type env tres then begin
    4040        let res = Env.fresh_ident "_res" in
    41         TFun(TVoid [], Some((res, TPtr(tres', [])) :: args'), vararg, attr)
     41        TFun(TVoid [], Some((res, TPtr(Any, tres', [])) :: args'), vararg, attr)
    4242      end else
    4343        TFun(tres', Some args', vararg, attr)
    44   | TPtr(t1, attr) ->
     44  | TPtr(sp, t1, attr) ->
    4545      let t1' = transf_type env t1 in
    46       if t1' = t1 then t else TPtr(transf_type env t1, attr)
    47   | TArray(t1, sz, attr) ->
     46      if t1' = t1 then t else TPtr(sp, transf_type env t1, attr)
     47  | TArray(sp, t1, sz, attr) ->
    4848      let t1' = transf_type env t1 in
    49       if t1' = t1 then t else TArray(transf_type env t1, sz, attr)
     49      if t1' = t1 then t else TArray(sp, transf_type env t1, sz, attr)
    5050  | _ -> t
    5151
     
    5353  let t = transf_type env t in
    5454  if is_composite_type env t
    55   then (id, TPtr(add_attributes_type [AConst] t, []))
     55  then (id, TPtr(Any, add_attributes_type [AConst] t, []))
    5656  else (id, t)
    5757
     
    6161let rec transf_expr env e =
    6262  { etyp = transf_type env e.etyp;
     63    espace = e.espace;
    6364    edesc = match e.edesc with
    6465      | EConst c -> EConst c
     
    105106  let e' = transf_expr e in
    106107  if is_composite_type env e'.etyp
    107   then {edesc = EUnop(Oaddrof, e'); etyp = TPtr(e'.etyp, [])}
     108  then {edesc = EUnop(Oaddrof, e'); etyp = TPtr(Any, e'.etyp, []); espace = Any} (* XXX: this might require a cast? *)
    108109  else e'
    109110in
     
    119120  match s.sdesc with
    120121  | Sskip -> s
    121   | Sdo {edesc = ECall(fn, args); etyp = ty} ->
     122  | Sdo {edesc = ECall(fn, args); etyp = ty; espace = space} ->
    122123      let fn = transf_expr fn in
    123124      let args = List.map transf_arg args in
    124125      if is_composite_type env ty then begin
    125126        let tmp = new_temp ~name:"_res" ty in
    126         let arg0 = {edesc = EUnop(Oaddrof, tmp); etyp = TPtr(ty, [])} in
    127         {s with sdesc = Sdo {edesc = ECall(fn, arg0 :: args); etyp = TVoid []}}
     127        let arg0 = {edesc = EUnop(Oaddrof, tmp); etyp = TPtr(Any, ty, []); espace = Any} in
     128        {s with sdesc = Sdo {edesc = ECall(fn, arg0 :: args); etyp = TVoid []; espace = Any}}
    128129      end else
    129         {s with sdesc = Sdo {edesc = ECall(fn, args); etyp = ty}}
    130   | Sdo {edesc = EBinop(Oassign, dst, {edesc = ECall(fn, args); etyp = ty}, _)} ->
     130        {s with sdesc = Sdo {edesc = ECall(fn, args); etyp = ty; espace = space}}
     131  | Sdo {edesc = EBinop(Oassign, dst, {edesc = ECall(fn, args); etyp = ty; espace = space}, _)} ->
    131132      let dst = transf_expr dst in
    132133      let fn = transf_expr fn in
     
    134135      let ty = transf_type ty in
    135136      if is_composite_type env ty then begin
    136         let arg0 = {edesc = EUnop(Oaddrof, dst); etyp = TPtr(dst.etyp, [])} in
    137         {s with sdesc = Sdo {edesc = ECall(fn, arg0 :: args); etyp = TVoid []}}
     137        let arg0 = {edesc = EUnop(Oaddrof, dst); etyp = TPtr(Any, dst.etyp, []); espace = Any} in
     138        {s with sdesc = Sdo {edesc = ECall(fn, arg0 :: args); etyp = TVoid []; espace = Any}}
    138139      end else
    139         sassign s.sloc dst {edesc = ECall(fn, args); etyp = ty}
     140        sassign s.sloc dst {edesc = ECall(fn, args); etyp = ty; espace = space}
    140141  | Sdo e ->
    141142      {s with sdesc = Sdo(transf_expr e)}
     
    185186      if is_composite_type env ty then begin
    186187        let id' = Env.fresh_ident id.name in
    187         let ty' = TPtr(add_attributes_type [AConst] ty, []) in
     188        let ty' = TPtr(Any, add_attributes_type [AConst] ty, []) in
    188189        let (params', decls, init) = transf_prm params in
    189190        ((id', ty') :: params',
    190191         (Storage_default, id, ty, None) :: decls,
    191192         sseq loc
    192           (sassign loc {edesc = EVar id; etyp = ty}
    193                        {edesc = EUnop(Oderef, {edesc = EVar id'; etyp = ty'});
    194                         etyp = ty})
     193          (sassign loc {edesc = EVar id; etyp = ty; espace = Any}
     194                       {edesc = EUnop(Oderef, {edesc = EVar id'; etyp = ty'; espace = Any});
     195                        etyp = ty;
     196                        espace = Any})
    195197          init)
    196198      end else begin
     
    207209    if is_composite_type env ret then begin
    208210      let vres = Env.fresh_ident "_res" in
    209       let tres = TPtr(ret, []) in
    210       let eres = {edesc = EVar vres; etyp = tres} in
    211       let eeres = {edesc = EUnop(Oderef, eres); etyp = ret} in
     211      let tres = TPtr(Any, ret, []) in
     212      let eres = {edesc = EVar vres; etyp = tres; espace = Any} in
     213      let eeres = {edesc = EUnop(Oderef, eres); etyp = ret; espace = Any} in
    212214      (TVoid [],
    213215       (vres, tres) :: params,
Note: See TracChangeset for help on using the changeset viewer.