From cb902b29bb53d2efefcc6e86df8b247dfa8abb84 Mon Sep 17 00:00:00 2001 From: Bourgerie Quentin Date: Tue, 24 Jul 2012 13:48:15 +0200 Subject: [PATCH] [enhance] compiler, jsident: @js_ident resolution should take care of the client renaming --- compiler/opa/opa_ResolveJsIdent.ml | 9 +++++---- compiler/opa/opa_ResolveJsIdent.mli | 12 +++++++----- compiler/opa/s3Passes.ml | 4 +++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/compiler/opa/opa_ResolveJsIdent.ml b/compiler/opa/opa_ResolveJsIdent.ml index e1aa5521..f0c735a0 100644 --- a/compiler/opa/opa_ResolveJsIdent.ml +++ b/compiler/opa/opa_ResolveJsIdent.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) diff --git a/compiler/opa/opa_ResolveJsIdent.mli b/compiler/opa/opa_ResolveJsIdent.mli index 3912296f..47e4c63d 100644 --- a/compiler/opa/opa_ResolveJsIdent.mli +++ b/compiler/opa/opa_ResolveJsIdent.mli @@ -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 . *) -(** - 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 diff --git a/compiler/opa/s3Passes.ml b/compiler/opa/s3Passes.ml index a7a4db3c..e565023d 100644 --- a/compiler/opa/s3Passes.ml +++ b/compiler/opa/s3Passes.ml @@ -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 =