Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsexplain
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verified Software
jsexplain
Commits
1b11830b
Commit
1b11830b
authored
9 years ago
by
Thomas Wood
Browse files
Options
Downloads
Patches
Plain Diff
Rename 'loc' variable in places for consistency.
parent
80647a76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generator/js_of_ast.ml
+30
-30
30 additions, 30 deletions
generator/js_of_ast.ml
with
30 additions
and
30 deletions
generator/js_of_ast.ml
+
30
−
30
View file @
1b11830b
...
...
@@ -205,9 +205,9 @@ and js_of_branch b obj =
in
L
.
log_line
(
ppf_branch
spat
binders
se
)
(
L
.
Add
(
binders
,
typ
))
and
js_of_expression
e
=
let
loc
n
=
e
.
exp_loc
in
let
loc
=
e
.
exp_loc
in
match
e
.
exp_desc
with
|
Texp_ident
(
_
,
loc
,
_
)
->
js_of_longident
loc
|
Texp_ident
(
_
,
ident
,
_
)
->
js_of_longident
ident
|
Texp_constant
c
->
js_of_constant
c
|
Texp_let
(
_
,
vb_l
,
e
)
->
let
sd
=
String
.
concat
lin1
@@
List
.
map
(
fun
vb
->
show_value_binding
vb
)
@@
vb_l
in
...
...
@@ -224,9 +224,9 @@ and js_of_expression e =
in
ppf_function
args
body
|
Texp_apply
(
f
,
exp_l
)
->
let
sl'
=
exp_l
|>
List
.
map
(
fun
(
_
,
eo
,
_
)
->
match
eo
with
None
->
out_of_scope
loc
n
"optional apply arguments"
|
Some
ei
->
ei
)
in
|>
List
.
map
(
fun
(
_
,
eo
,
_
)
->
match
eo
with
None
->
out_of_scope
loc
"optional apply arguments"
|
Some
ei
->
ei
)
in
let
sl
=
exp_l
|>
List
.
map
(
fun
(
_
,
eo
,
_
)
->
match
eo
with
None
->
out_of_scope
loc
n
"optional apply arguments"
|
Some
ei
->
js_of_expression
ei
)
in
|>
List
.
map
(
fun
(
_
,
eo
,
_
)
->
match
eo
with
None
->
out_of_scope
loc
"optional apply arguments"
|
Some
ei
->
js_of_expression
ei
)
in
let
se
=
js_of_expression
f
in
if
is_infix
f
sl'
&&
List
.
length
exp_l
=
2
then
ppf_apply_infix
se
(
List
.
hd
sl
)
(
List
.
hd
(
List
.
tl
sl
))
...
...
@@ -239,7 +239,7 @@ and js_of_expression e =
|
Texp_tuple
(
tl
)
->
ppf_tuple
@@
show_list_f
(
fun
exp
->
js_of_expression
exp
)
", "
tl
|
Texp_construct
(
loc
,
cd
,
el
)
->
|
Texp_construct
(
_
,
cd
,
el
)
->
let
name
=
cd
.
cstr_name
in
if
el
=
[]
then
(* Constructor has no parameters *)
if
is_sbool
name
then
name
(* Special case true/false to their JS natives *)
...
...
@@ -261,22 +261,22 @@ and js_of_expression e =
|
Texp_field
(
exp
,
_
,
lbl
)
->
ppf_field_access
(
js_of_expression
exp
)
lbl
.
lbl_name
|
Texp_match
(
_
,_,_,
Partial
)
->
out_of_scope
loc
n
"partial matching"
|
Texp_match
(
_
,_,_,_
)
->
out_of_scope
loc
n
"matching with exception branches"
|
Texp_try
(
_
,_
)
->
out_of_scope
loc
n
"exceptions"
|
Texp_function
(
_
,_,_
)
->
out_of_scope
loc
n
"powered-up functions"
|
Texp_variant
(
_
,_
)
->
out_of_scope
loc
n
"polymorphic variant"
|
Texp_setfield
(
_
,_,_,_
)
->
out_of_scope
loc
n
"setting field"
|
Texp_send
(
_
,_,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_new
(
_
,_,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_instvar
(
_
,_,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_setinstvar
(
_
,_,_,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_override
(
_
,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_letmodule
(
_
,_,_,_
)
->
out_of_scope
loc
n
"local modules"
|
Texp_assert
_
->
out_of_scope
loc
n
"assert"
|
Texp_lazy
_
->
out_of_scope
loc
n
"lazy expressions"
|
Texp_object
(
_
,_
)
->
out_of_scope
loc
n
"objects"
|
Texp_pack
_
->
out_of_scope
loc
n
"packing"
|
Texp_match
(
_
,_,_,
Partial
)
->
out_of_scope
loc
"partial matching"
|
Texp_match
(
_
,_,_,_
)
->
out_of_scope
loc
"matching with exception branches"
|
Texp_try
(
_
,_
)
->
out_of_scope
loc
"exceptions"
|
Texp_function
(
_
,_,_
)
->
out_of_scope
loc
"powered-up functions"
|
Texp_variant
(
_
,_
)
->
out_of_scope
loc
"polymorphic variant"
|
Texp_setfield
(
_
,_,_,_
)
->
out_of_scope
loc
"setting field"
|
Texp_send
(
_
,_,_
)
->
out_of_scope
loc
"objects"
|
Texp_new
(
_
,_,_
)
->
out_of_scope
loc
"objects"
|
Texp_instvar
(
_
,_,_
)
->
out_of_scope
loc
"objects"
|
Texp_setinstvar
(
_
,_,_,_
)
->
out_of_scope
loc
"objects"
|
Texp_override
(
_
,_
)
->
out_of_scope
loc
"objects"
|
Texp_letmodule
(
_
,_,_,_
)
->
out_of_scope
loc
"local modules"
|
Texp_assert
_
->
out_of_scope
loc
"assert"
|
Texp_lazy
_
->
out_of_scope
loc
"lazy expressions"
|
Texp_object
(
_
,_
)
->
out_of_scope
loc
"objects"
|
Texp_pack
_
->
out_of_scope
loc
"packing"
and
js_of_constant
=
function
|
Const_int
n
->
string_of_int
n
...
...
@@ -311,12 +311,12 @@ and js_of_let_pattern pat expr =
|
_
->
error
~
loc
:
pat
.
pat_loc
"let can't deconstruct values"
and
js_of_pattern
pat
obj
=
let
loc
n
=
pat
.
pat_loc
in
let
loc
=
pat
.
pat_loc
in
match
pat
.
pat_desc
with
|
Tpat_any
->
"default"
,
""
|
Tpat_constant
c
->
js_of_constant
c
,
""
|
Tpat_var
(
id
,
_
)
->
Ident
.
name
id
,
""
|
Tpat_construct
(
loc
,
cd
,
el
)
->
|
Tpat_construct
(
_
,
cd
,
el
)
->
let
c
=
cd
.
cstr_name
in
let
spat
=
Printf
.
sprintf
"%s"
(
"case
\"
"
^
c
^
"
\"
"
)
in
let
params
=
extract_attrs
cd
.
cstr_attributes
in
...
...
@@ -325,13 +325,13 @@ and js_of_pattern pat obj =
else
Printf
.
sprintf
"@[<v 0>%s@]"
(
"var "
^
show_list
", "
(
List
.
map2
(
fun
x
y
->
x
^
" = "
^
obj
^
"."
^
y
)
(
List
.
map
(
fun
x
->
fst
(
js_of_pattern
x
obj
))
el
)
params
)
^
";"
)
in
spat
,
binders
|
Tpat_tuple
el
->
unsupported
~
loc
:
locn
"tuple matching"
|
Tpat_array
el
->
unsupported
~
loc
:
locn
"array-match"
|
Tpat_record
(
_
,_
)
->
unsupported
~
loc
:
locn
"record"
|
Tpat_or
(
_
,_,_
)
->
error
~
loc
:
locn
"not implemented yet"
|
Tpat_alias
(
_
,_,_
)
->
out_of_scope
loc
n
"alias-pattern"
|
Tpat_variant
(
_
,_,_
)
->
out_of_scope
loc
n
"polymorphic variants in pattern matching"
|
Tpat_lazy
_
->
out_of_scope
loc
n
"lazy-pattern"
|
Tpat_tuple
el
->
unsupported
~
loc
"tuple matching"
|
Tpat_array
el
->
unsupported
~
loc
"array-match"
|
Tpat_record
(
_
,_
)
->
unsupported
~
loc
"record"
|
Tpat_or
(
_
,_,_
)
->
error
~
loc
"not implemented yet"
|
Tpat_alias
(
_
,_,_
)
->
out_of_scope
loc
"alias-pattern"
|
Tpat_variant
(
_
,_,_
)
->
out_of_scope
loc
"polymorphic variants in pattern matching"
|
Tpat_lazy
_
->
out_of_scope
loc
"lazy-pattern"
let
to_javascript
module_name
typedtree
=
let
content
=
js_of_structure
typedtree
in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment