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
f949c5cd
Commit
f949c5cd
authored
9 years ago
by
Paul IANNETTA
Committed by
Thomas Wood
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
last changes
parent
70197c81
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
generator/attributes.ml
+12
-4
12 additions, 4 deletions
generator/attributes.ml
generator/js_of_ast.ml
+34
-2
34 additions, 2 deletions
generator/js_of_ast.ml
generator/parse_type.ml
+1
-1
1 addition, 1 deletion
generator/parse_type.ml
with
47 additions
and
7 deletions
generator/attributes.ml
+
12
−
4
View file @
f949c5cd
...
@@ -3,13 +3,21 @@ open Parsetree
...
@@ -3,13 +3,21 @@ open Parsetree
open
Typedtree
open
Typedtree
open
Mytools
open
Mytools
let
rec
extract_cstr_attrs
(
cstr
:
Typedtree
.
constructor_declaration
)
:
string
*
string
list
=
let
rec
extract_cstr_attrs
(
cstr
:
Typedtree
.
constructor_declaration
)
=
let
cstr_name
=
Ident
.
name
cstr
.
cd_id
in
let
cstr_name
=
Ident
.
name
cstr
.
cd_id
in
let
cstr_params
=
cstr
.
cd_attributes
let
cstr_params
=
extract_attrs
cstr
.
cd_attributes
|>
List
.
map
(
fun
(
_
,
pl
)
->
extract_payload
pl
)
|>
List
.
flatten
in
(
cstr_name
,
cstr_params
)
in
(
cstr_name
,
cstr_params
)
and
extract_vb_attrs
(
vb
:
Typedtree
.
value_binding
)
=
extract_attrs
vb
.
vb_attributes
and
extract_attrs
attrs
=
attrs
|>
List
.
map
extract_attr
|>
List
.
flatten
and
extract_attr
(
_
,
pl
)
=
extract_payload
pl
and
extract_payload
=
function
and
extract_payload
=
function
|
PStr
s
->
extract_structure
s
|
PStr
s
->
extract_structure
s
|
PTyp
_
->
error
"Type found. A tuple or a single value was expected"
|
PTyp
_
->
error
"Type found. A tuple or a single value was expected"
...
...
This diff is collapsed.
Click to expand it.
generator/js_of_ast.ml
+
34
−
2
View file @
f949c5cd
...
@@ -110,11 +110,38 @@ let ppf_single_cstrs typ =
...
@@ -110,11 +110,38 @@ let ppf_single_cstrs typ =
let
ppf_multiple_cstrs
typ
rest
=
let
ppf_multiple_cstrs
typ
rest
=
Format
.
sprintf
"{type:
\"
%s
\"
, %s}"
Format
.
sprintf
"{type:
\"
%s
\"
, %s}"
typ
rest
typ
rest
(**
* Log Part
*)
module
Log
:
sig
val
status
:
unit
->
bool
val
init_log
:
unit
->
unit
val
toggle
:
string
->
unit
end
=
struct
let
s
=
ref
false
let
status
()
=
!
s
let
init_log
()
=
s
:=
false
let
toggle
update
=
match
update
with
|
"logged"
->
s
:=
true
;
|
"unlogged"
->
s
:=
false
;
|
_
->
()
;
end
(**
(**
* Main part
* Main part
*)
*)
(*let to_javascript typedtree =
js_of_structure typedtree
(** + Log related post processing **)
*)
let
rec
show_value_binding
vb
=
let
rec
show_value_binding
vb
=
js_of_let_pattern
vb
.
vb_pat
vb
.
vb_expr
js_of_let_pattern
vb
.
vb_pat
vb
.
vb_expr
...
@@ -145,7 +172,12 @@ and js_of_structure_item s = match s.str_desc with
...
@@ -145,7 +172,12 @@ and js_of_structure_item s = match s.str_desc with
|
Tstr_class
_
->
out_of_scope
"objects"
|
Tstr_class
_
->
out_of_scope
"objects"
|
Tstr_class_type
_
->
out_of_scope
"class types"
|
Tstr_class_type
_
->
out_of_scope
"class types"
|
Tstr_include
_
->
out_of_scope
"includes"
|
Tstr_include
_
->
out_of_scope
"includes"
|
Tstr_attribute
_
->
out_of_scope
"attributes"
|
Tstr_attribute
attrs
->
let
log_status
=
match
extract_attr
attrs
with
|
[]
->
""
|
x
::
xs
->
x
in
Log
.
toggle
log_status
;
""
and
js_of_branch
b
obj
=
and
js_of_branch
b
obj
=
let
spat
,
binders
=
js_of_pattern
b
.
c_lhs
obj
in
let
spat
,
binders
=
js_of_pattern
b
.
c_lhs
obj
in
...
...
This diff is collapsed.
Click to expand it.
generator/parse_type.ml
+
1
−
1
View file @
f949c5cd
...
@@ -29,7 +29,7 @@ let initial_env () =
...
@@ -29,7 +29,7 @@ let initial_env () =
then
Env
.
open_pers_signature
"Stdlib"
Env
.
initial_unsafe_string
then
Env
.
open_pers_signature
"Stdlib"
Env
.
initial_unsafe_string
else
Env
.
open_pers_signature
"Stdlib"
Env
.
initial_unsafe_string
else
Env
.
open_pers_signature
"Stdlib"
Env
.
initial_unsafe_string
with
Not_found
->
with
Not_found
->
fatal_error
"cannot open
pervasives
"
fatal_error
"cannot open
stdlib
"
(** Optionally preprocess a source file *)
(** Optionally preprocess a source file *)
let
preprocess
sourcefile
=
let
preprocess
sourcefile
=
...
...
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