Skip to content
This repository
tag: v1880
Fetching contributors…

Cannot retrieve contributors at this time

file 165 lines (135 sloc) 6.758 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
Javascript Constructor Helpers
@author Mathieu Barbin
*)

module Expr :
sig
  val array : ?label:Annot.label -> JsAst.expr list -> JsAst.expr

  val assign : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val assign_ident : ?label:Annot.label -> JsAst.ident -> JsAst.expr -> JsAst.expr
  val binop : ?label:Annot.label -> JsAst.binop -> JsAst.expr -> JsAst.expr -> JsAst.expr

  val true_ : ?label:Annot.label -> unit -> JsAst.expr
  val false_ : ?label:Annot.label -> unit -> JsAst.expr

  val bool : ?label:Annot.label -> bool -> JsAst.expr
  val call : ?label:Annot.label -> pure:bool -> JsAst.expr -> JsAst.expr list -> JsAst.expr
  val cond : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr -> JsAst.expr

  (**
Do not build a comma when the prefix list is empty,
simply returns the expr.
*)
  val comma : ?label:Annot.label -> JsAst.expr list -> JsAst.expr -> JsAst.expr
  val dot : ?label:Annot.label -> JsAst.expr -> string -> JsAst.expr
  val equality : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val exprident : ?label:Annot.label -> Ident.t -> JsAst.expr

  (**
Build a local native ident.
Global native ident should rather not be created directly, but produced with an analysis, except for identifer known statically to be global.
*)
  val native : ?label:Annot.label -> string -> JsAst.expr
  val native_global : ?label:Annot.label -> string -> JsAst.expr



  (**
@deprecated use [dot] instead
*)
  val field : ?label:Annot.label -> JsAst.expr -> string -> JsAst.expr
  val float : ?label:Annot.label -> float -> JsAst.expr
  val function_: ?label:Annot.label -> JsAst.ident option -> JsAst.ident list -> JsAst.statement list -> JsAst.expr
  val greater : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val hashref : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val hole : ?label:Annot.label -> QmlAst.expr -> JsAst.expr
  val ident : ?label:Annot.label -> JsAst.ident -> JsAst.expr
  val in_ : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val int : ?label:Annot.label -> int -> JsAst.expr
  val int_as_string : ?label:Annot.label -> string -> JsAst.expr
  val land_ : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val list : ?label:Annot.label -> JsAst.expr list -> JsAst.expr
  val lor_ : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val neq : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val not_ : ?label:Annot.label -> JsAst.expr -> JsAst.expr
  val null : ?label:Annot.label -> unit -> JsAst.expr
  val obj : ?label:Annot.label -> (string * JsAst.expr) list -> JsAst.expr
  val runtime : ?label:Annot.label -> JsAstRuntime.expr -> JsAst.expr
  val strict_equality : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val strict_neq : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.expr
  val string : ?label:Annot.label -> string -> JsAst.expr
  val this : ?label:Annot.label -> unit -> JsAst.expr
  val unop : ?label:Annot.label -> JsAst.unop -> JsAst.expr -> JsAst.expr
  val undefined : ?label:Annot.label -> unit -> JsAst.expr

  (* builds (function(){ var [idents]; return [expr]})() *)
  val scope : JsIdent.t list -> JsAst.expr -> JsAst.expr
  (* as scope, but just return the expression when the list of local vars is empty *)
  val maybe_scope : JsIdent.t list -> JsAst.expr -> JsAst.expr

  (** {6 Deprecated API} *)

  (**
Used in the transition between jslang/jslang2.
*)

  (**
After the transition, remove this function, and use [comma] combine with [affect] instead.
It is preferable to lift affectation to the higher level of the current scope, rather than
having imbrication of affectation. (lisibility of code for debuging)
*)
  val deprecated_letin : ?label:Annot.label -> (JsAst.ident * JsAst.expr) list -> JsAst.expr -> JsAst.expr

  (**
After the transition, remove this function, and use [function_] instead
*)
  val deprecated_lambda :
    ?label:Annot.label ->
    JsAst.ident list ->
    JsAst.ident list ->
    JsAst.expr ->
    JsAst.expr
end

module Statement :
sig
  val def : ?label:Annot.label -> JsAst.ident -> JsAst.statement

  val assign : ?label:Annot.label -> JsAst.expr -> JsAst.expr -> JsAst.statement
  val assign_ident : ?label:Annot.label -> JsAst.ident -> JsAst.expr -> JsAst.statement
  val block : ?label:Annot.label -> JsAst.statement list -> JsAst.statement
  val continue : ?label:Annot.label -> ?label:JsAst.label -> unit -> JsAst.statement
  val comment : ?label:Annot.label -> ?kind:[`doc|`simple|`one_line] -> string -> JsAst.statement
  val expr : ?label:Annot.label -> JsAst.expr -> JsAst.statement
  val function_ : ?label:Annot.label -> JsAst.ident -> JsAst.ident list -> JsAst.statement list -> JsAst.statement
  val if_ : ?label:Annot.label -> JsAst.expr -> JsAst.statement -> JsAst.statement -> JsAst.statement
  val if_no_else : ?label:Annot.label -> JsAst.expr -> JsAst.statement -> JsAst.statement
  val return : ?label:Annot.label -> JsAst.expr -> JsAst.statement
  val switch : ?label:Annot.label -> ?default:JsAst.statement -> JsAst.expr -> (JsAst.expr * JsAst.statement) list -> JsAst.statement
  val var : ?label:Annot.label -> ?expr:JsAst.expr -> JsAst.ident -> JsAst.statement
  val while_ : ?label:Annot.label -> JsAst.expr -> JsAst.statement -> JsAst.statement

  (** {6 Deprecated API} *)

  (**
Used in the transition between jslang/jslang2.
*)

  (**
After the transition, remove this function, and use [function_] instead
*)
  val deprecated_function :
    ?label:Annot.label ->
    JsAst.ident -> JsAst.ident list ->
    JsAst.ident list ->
    JsAst.expr ->
    JsAst.statement
end

module Ident :
sig
  val ident : Ident.t -> JsAst.ident


  val fresh : JsAst.ident -> JsAst.ident
  val fresh_qml : Ident.t -> JsAst.ident

  (**
Build a local native ident.
Global native ident should rather not be created directly, but produced with an analysis.
*)
  val native : string -> JsAst.ident
  val native_global : string -> JsAst.ident



end
Something went wrong with that request. Please try again.