Skip to content
This repository
Browse code

[fix] compiler, oparpc: Take care of renaming when serialize toplevel…

… value with opa2js
  • Loading branch information...
commit 84f2d859c8e0fc154a52887c553136c4b443298e 1 parent 2761234
Quentin Bourgerie authored September 10, 2012

Showing 1 changed file with 13 additions and 4 deletions. Show diff stats Hide diff stats

  1. 17  compiler/opa/opa_InsertRemote.ml
17  compiler/opa/opa_InsertRemote.ml
@@ -1211,8 +1211,10 @@ let select_publish_resolver _n =
1211 1211
 
1212 1212
 (** Insert resolver. Produce a directive for qmljs. Its goal is to
1213 1213
     insert server value on client code. *)
1214  
-let insert_resolver0_unoptimized ~annotmap ~stdlib_gamma ~gamma ~side (`insert_server_value ident) _id ty =
  1214
+let insert_resolver0_unoptimized ~renaming ~annotmap ~stdlib_gamma ~gamma ~side
  1215
+    (`insert_server_value ident) _id ty =
1215 1216
   assert(side = `client);
  1217
+  ignore (renaming);
1216 1218
   _insert ();
1217 1219
   let add_missing_string_arg annotmap func args =
1218 1220
     let string_arg = Ident.next "expand_missing_string_arg" in
@@ -1252,7 +1254,7 @@ let insert_resolver0_unoptimized ~annotmap ~stdlib_gamma ~gamma ~side (`insert_s
1252 1254
 
1253 1255
 (** Second version for insert resolver. More optimized but not stable
1254 1256
     : back-end and implementation dependent (see opa2js.opa). *)
1255  
-let insert_resolver1_optimized ~annotmap ~stdlib_gamma ~gamma ~side (`insert_server_value ident) id ty =
  1257
+let insert_resolver1_optimized ~renaming ~annotmap ~stdlib_gamma ~gamma ~side (`insert_server_value ident) id ty =
1256 1258
   assert(side = `client);
1257 1259
   _insert ();
1258 1260
   (* Make server expr *)
@@ -1261,7 +1263,14 @@ let insert_resolver1_optimized ~annotmap ~stdlib_gamma ~gamma ~side (`insert_ser
1261 1263
   let annotmap, ser =
1262 1264
     Opa2Js.to_string ~side:(OpaMapToIdent.other_side side) annotmap stdlib_gamma in
1263 1265
   let annotmap, serv_expr =
1264  
-    let annotmap, toplevel_var = TypedExpr.string annotmap (JsPrint.string_of_ident (JsAst.ExprIdent id)) in
  1266
+    let annotmap, toplevel_var =
  1267
+      let id =
  1268
+        try
  1269
+          QmlRenamingMap.original_from_new renaming id
  1270
+        with Not_found -> id
  1271
+      in
  1272
+      TypedExpr.string annotmap (JsPrint.string_of_ident (JsAst.ExprIdent id))
  1273
+    in
1265 1274
     let annotmap, expr = TypedExpr.ident annotmap ident ty in
1266 1275
     full_apply gamma annotmap ser [ty_expr_server] [toplevel_var; expr]
1267 1276
   in
@@ -1405,7 +1414,7 @@ let perform_on_code ?(options=default_options) side ~annotmap ~stdlib_gamma ~gam
1405 1414
       ((select_publish_resolver options.optimize_publish) expmap1 renaming1)
1406 1415
       (generate_stub_from_publish expmap1 renaming1)
1407 1416
       (call_resolver expmap2 renaming2)
1408  
-      (select_insert_resolver options.optimize_insert) in
  1417
+      (select_insert_resolver options.optimize_insert ~renaming:renaming1) in
1409 1418
 
1410 1419
   (* let annotmap, gamma, code = *)
1411 1420
   (*   #<If:RPC_ALT_SKELETON> *)

0 notes on commit 84f2d85

Please sign in to comment.
Something went wrong with that request. Please try again.