Skip to content

Commit

Permalink
[enhance] compiler, jsident: @js_ident resolution should take care of…
Browse files Browse the repository at this point in the history
… the client renaming
  • Loading branch information
BourgerieQuentin committed Jul 24, 2012
1 parent 1ba12b2 commit cb902b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 5 additions & 4 deletions compiler/opa/opa_ResolveJsIdent.ml
@@ -1,5 +1,5 @@
(* (*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of Opa. This file is part of Opa.
Expand All @@ -24,7 +24,7 @@ module JsIdent = Qmljs_Serializer.JsIdent
module Q = QmlAst module Q = QmlAst


(* TODO - Merge it on JavaScriptCompilation *) (* TODO - Merge it on JavaScriptCompilation *)
let resolve annotmap code = let resolve annotmap code renaming =
QmlAstWalk.CodeExpr.fold_map QmlAstWalk.CodeExpr.fold_map
(QmlAstWalk.Expr.foldmap (QmlAstWalk.Expr.foldmap
(fun annotmap expr -> (fun annotmap expr ->
Expand All @@ -39,6 +39,7 @@ let resolve annotmap code =
in in
let jsident = let jsident =
let ident = OpaMapToIdent.val_ ~side:`client name in let ident = OpaMapToIdent.val_ ~side:`client name in
let ident = QmlRenamingMap.original_from_new renaming ident in
JsIdent.resolve ident JsIdent.resolve ident
in in
QmlAstCons.TypedExpr.ident annotmap jsident QmlAstCons.TypedExpr.ty_string QmlAstCons.TypedExpr.ident annotmap jsident QmlAstCons.TypedExpr.ty_string
Expand All @@ -54,7 +55,7 @@ let resolve annotmap code =
) )
annotmap code annotmap code


let perform annotmap code = let perform annotmap code renaming =
let annotmap, code = resolve annotmap code in let annotmap, code = resolve annotmap code renaming in
let decls = JsIdent.get_toplevel_declarations () in let decls = JsIdent.get_toplevel_declarations () in
annotmap, (decls @ code) annotmap, (decls @ code)
12 changes: 7 additions & 5 deletions compiler/opa/opa_ResolveJsIdent.mli
@@ -1,5 +1,5 @@
(* (*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of Opa. This file is part of Opa.
Expand All @@ -15,9 +15,11 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with Opa. If not, see <http://www.gnu.org/licenses/>. along with Opa. If not, see <http://www.gnu.org/licenses/>.
*) *)
(** (** Replace all directive [js_ident]. These directive are typically use to
Replace all directive js_ident generates adhoc (i.e. backend specific) JavaScript code but using Opa
FIXME: author ? identifier.
@author Quentin Bourgerie
*) *)


(** (**
Expand All @@ -39,4 +41,4 @@
t(x) = "{_v0_toto}(x, y)" 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
4 changes: 3 additions & 1 deletion compiler/opa/s3Passes.ml
Expand Up @@ -1852,7 +1852,9 @@ let pass_ResolveJsIdent =
let annotmap, code = let annotmap, code =
Opa_ResolveJsIdent.perform Opa_ResolveJsIdent.perform
env.P.newFinalCompile_qml_milkshake.QmlBlender.env.QmlTypes.annotmap 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 = let env =
{ env with P. { env with P.
newFinalCompile_qml_milkshake = newFinalCompile_qml_milkshake =
Expand Down

0 comments on commit cb902b2

Please sign in to comment.