Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (52 sloc) 2.256 kB
fccc685 Initial open-source release
MLstate authored
1 (*
cb902b2 @BourgerieQuentin [enhance] compiler, jsident: @js_ident resolution should take care of…
BourgerieQuentin authored
2 Copyright © 2011, 2012 MLstate
fccc685 Initial open-source release
MLstate authored
3
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
4 This file is part of Opa.
fccc685 Initial open-source release
MLstate authored
5
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
6 Opa is free software: you can redistribute it and/or modify it under the
fccc685 Initial open-source release
MLstate authored
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
10 Opa is distributed in the hope that it will be useful, but WITHOUT ANY
fccc685 Initial open-source release
MLstate authored
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
5bb0f1a @Aqua-Ye [cleanup] compiler: typo on Opa
Aqua-Ye authored
16 along with Opa. If not, see <http://www.gnu.org/licenses/>.
fccc685 Initial open-source release
MLstate authored
17 *)
18 (* CF mli *)
19
20 (* alias *)
21 module JsIdent = Qmljs_Serializer.JsIdent
22
23 (* shorthands *)
24 module Q = QmlAst
25
26 (* TODO - Merge it on JavaScriptCompilation *)
cb902b2 @BourgerieQuentin [enhance] compiler, jsident: @js_ident resolution should take care of…
BourgerieQuentin authored
27 let resolve annotmap code renaming =
fccc685 Initial open-source release
MLstate authored
28 QmlAstWalk.CodeExpr.fold_map
29 (QmlAstWalk.Expr.foldmap
30 (fun annotmap expr ->
31 match expr with
32 | Q.Directive (_, `js_ident, [Q.Const (_, Q.String name)], []) ->
33 (try
34 let name =
35 try Hashtbl.find Opacapi.table name
36 with Not_found ->
37 QmlError.error (QmlError.Context.annoted_expr annotmap expr)
38 "Not registered in Opacapi"
39 in
40 let jsident =
41 let ident = OpaMapToIdent.val_ ~side:`client name in
cb902b2 @BourgerieQuentin [enhance] compiler, jsident: @js_ident resolution should take care of…
BourgerieQuentin authored
42 let ident = QmlRenamingMap.original_from_new renaming ident in
fccc685 Initial open-source release
MLstate authored
43 JsIdent.resolve ident
44 in
45 QmlAstCons.TypedExpr.ident annotmap jsident QmlAstCons.TypedExpr.ty_string
46 with Not_found ->
47 QmlError.error (QmlError.Context.annoted_expr annotmap expr)
48 "Doesn't exists on client side")
49
50 | Q.Directive (_, `js_ident, _, _) ->
51 QmlError.i_serror None (QmlError.Context.annoted_expr annotmap expr) "Malformed directive";
52 (annotmap, expr)
53 | _ -> (annotmap, expr)
54 )
55 )
56 annotmap code
57
cb902b2 @BourgerieQuentin [enhance] compiler, jsident: @js_ident resolution should take care of…
BourgerieQuentin authored
58 let perform annotmap code renaming =
59 let annotmap, code = resolve annotmap code renaming in
fccc685 Initial open-source release
MLstate authored
60 let decls = JsIdent.get_toplevel_declarations () in
61 annotmap, (decls @ code)
Something went wrong with that request. Please try again.