Permalink
Browse files

[enhance] compiler, jsident: @js_ident resolution should take care of…

… the client renaming
  • Loading branch information...
1 parent 1ba12b2 commit cb902b29bb53d2efefcc6e86df8b247dfa8abb84 @BourgerieQuentin BourgerieQuentin committed Jul 24, 2012
Showing with 15 additions and 10 deletions.
  1. +5 −4 compiler/opa/opa_ResolveJsIdent.ml
  2. +7 −5 compiler/opa/opa_ResolveJsIdent.mli
  3. +3 −1 compiler/opa/s3Passes.ml
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -24,7 +24,7 @@ module JsIdent = Qmljs_Serializer.JsIdent
module Q = QmlAst
(* TODO - Merge it on JavaScriptCompilation *)
-let resolve annotmap code =
+let resolve annotmap code renaming =
QmlAstWalk.CodeExpr.fold_map
(QmlAstWalk.Expr.foldmap
(fun annotmap expr ->
@@ -39,6 +39,7 @@ let resolve annotmap code =
in
let jsident =
let ident = OpaMapToIdent.val_ ~side:`client name in
+ let ident = QmlRenamingMap.original_from_new renaming ident in
JsIdent.resolve ident
in
QmlAstCons.TypedExpr.ident annotmap jsident QmlAstCons.TypedExpr.ty_string
@@ -54,7 +55,7 @@ let resolve annotmap code =
)
annotmap code
-let perform annotmap code =
- let annotmap, code = resolve annotmap code in
+let perform annotmap code renaming =
+ let annotmap, code = resolve annotmap code renaming in
let decls = JsIdent.get_toplevel_declarations () in
annotmap, (decls @ code)
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of Opa.
@@ -15,9 +15,11 @@
You should have received a copy of the GNU Affero General Public License
along with Opa. If not, see <http://www.gnu.org/licenses/>.
*)
-(**
- Replace all directive js_ident
- FIXME: author ?
+(** Replace all directive [js_ident]. These directive are typically use to
+ generates adhoc (i.e. backend specific) JavaScript code but using Opa
+ identifier.
+
+ @author Quentin Bourgerie
*)
(**
@@ -39,4 +41,4 @@
t(x) = "{_v0_toto}(x, y)"
]}
*)
-val perform : QmlAst.annotmap -> QmlAst.code -> QmlAst.annotmap * QmlAst.code
+val perform : QmlAst.annotmap -> QmlAst.code -> QmlRenamingMap.t -> QmlAst.annotmap * QmlAst.code
View
@@ -1852,7 +1852,9 @@ let pass_ResolveJsIdent =
let annotmap, code =
Opa_ResolveJsIdent.perform
env.P.newFinalCompile_qml_milkshake.QmlBlender.env.QmlTypes.annotmap
- env.P.newFinalCompile_qml_milkshake.QmlBlender.code in
+ env.P.newFinalCompile_qml_milkshake.QmlBlender.code
+ env.P.newFinalCompile_renaming_client
+ in
let env =
{ env with P.
newFinalCompile_qml_milkshake =

0 comments on commit cb902b2

Please sign in to comment.