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
1e2cfa59
Commit
1e2cfa59
authored
9 years ago
by
Cesar Roux Dit Buisson
Browse files
Options
Downloads
Patches
Plain Diff
Correct ctx creation and push
parent
71c7a334
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
generator/log.ml
+4
-2
4 additions, 2 deletions
generator/log.ml
generator/tests/log_source.js
+12
-12
12 additions, 12 deletions
generator/tests/log_source.js
navig.html
+2
-1
2 additions, 1 deletion
navig.html
with
18 additions
and
15 deletions
generator/log.ml
+
4
−
2
View file @
1e2cfa59
...
...
@@ -164,7 +164,7 @@ struct
let
ctx_processing
id
=
let
rec
aux
=
function
|
[]
->
""
|
x
::
xs
->
"
\n
"
^
pad
^
"ctx_push(ctx,
\"
"
^
x
^
"
\"
, "
^
x
^
",
\"
value
\"
);"
^
aux
xs
|
x
::
xs
->
"
\n
"
^
pad
^
"ctx
= ctx
_push(ctx,
\"
"
^
x
^
"
\"
, "
^
x
^
",
\"
value
\"
);"
^
aux
xs
in
id
|>
to_format
|>
Format
.
sprintf
|>
global_replace
(
regexp
"var "
)
""
|>
split
(
regexp
", "
)
|>
List
.
map
(
fun
x
->
List
.
hd
(
split
(
regexp
" = "
)
x
))
|>
aux
...
...
@@ -176,7 +176,9 @@ struct
Buffer
.
add_string
buf
str
;
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"var ctx = ctx_empty();"
);
(* Logging needs changing so we can use args actual name instead of t *)
List
.
map
(
fun
x
->
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"ctx_push(ctx,
\"
t
\"
, "
^
x
^
",
\"
expr
\"
);"
)
)
argslist
;
List
.
map
(
fun
x
->
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"ctx = ctx_push(ctx,
\"
"
^
x
^
"
\"
, "
^
x
^
",
\"
term
\"
);"
)
)
argslist
;
(* Find way to trickle actual function name in log call? *)
Buffer
.
add_string
buf
(
"
\n
"
^
pad
^
"log("
^
string_of_int
(
i
+
1
)
^
", ctx,
\"
function
\"
);"
);
aux
i
((
tks
,
str
)
::
xs
)
|
ReturnStrip
->
let
strsplit
=
split
(
regexp
"return"
)
str
in
...
...
This diff is collapsed.
Click to expand it.
generator/tests/log_source.js
+
12
−
12
View file @
1e2cfa59
...
...
@@ -30,19 +30,19 @@ var eval_ = function (expr) {
return
(
function
()
{
switch
(
expr
.
type
)
{
case
"
Const
"
:
var
n
=
expr
.
value
;
ctx_push
(
ctx
,
"
n
"
,
n
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
n
"
,
n
,
"
value
"
);
log
(
26
,
ctx
,
"
Const
"
);
return
n
;
case
"
Add
"
:
var
ls
=
expr
.
left
,
rs
=
expr
.
right
;
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
log
(
28
,
ctx
,
"
Add
"
);
return
call_wrap
(
29
,
ls
,
eval_
)
+
call_wrap
(
29
,
rs
,
eval_
);
case
"
Sub
"
:
var
ls
=
expr
.
left
,
rs
=
expr
.
right
;
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
log
(
30
,
ctx
,
"
Sub
"
);
return
(
function
()
{
log_custom
({
line
:
31
,
type
:
"
enter
"
});
...
...
@@ -52,19 +52,19 @@ var eval_ = function (expr) {
}());
case
"
Mul
"
:
var
ls
=
expr
.
left
,
rs
=
expr
.
right
;
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
log
(
32
,
ctx
,
"
Mul
"
);
return
call_wrap
(
33
,
line
,
eval_
)
*
call_wrap
(
33
,
rs
,
eval_
);
case
"
Div
"
:
var
ls
=
expr
.
left
,
rs
=
expr
.
right
;
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
ls
"
,
ls
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
rs
"
,
rs
,
"
value
"
);
log
(
34
,
ctx
,
"
Div
"
);
return
call_wrap
(
35
,
ls
,
eval_
)
/
call_wrap
(
35
,
rs
,
eval_
);
case
"
Pop
"
:
var
s
=
expr
.
stack
;
ctx_push
(
ctx
,
"
s
"
,
s
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
s
"
,
s
,
"
value
"
);
log
(
36
,
ctx
,
"
Pop
"
);
return
Stack
.
pop
(
call_wrap
(
37
,
s
,
evals
));
}
...
...
@@ -82,8 +82,8 @@ var evals = function (sexpr) {
case
"
Emp
"
:
return
{
type
:
"
Stack.N
"
};
case
"
Push
"
:
var
v
=
sexpr
.
value
,
s
=
sexpr
.
stack
;
ctx_push
(
ctx
,
"
v
"
,
v
,
"
value
"
);
ctx_push
(
ctx
,
"
s
"
,
s
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
v
"
,
v
,
"
value
"
);
ctx
=
ctx_push
(
ctx
,
"
s
"
,
s
,
"
value
"
);
log
(
48
,
ctx
,
"
Push
"
);
return
Stack
.
push
(
call_wrap
(
49
,
v
,
eval_
),
call_wrap
(
49
,
s
,
evals
));
...
...
This diff is collapsed.
Click to expand it.
navig.html
+
2
−
1
View file @
1e2cfa59
...
...
@@ -35,7 +35,8 @@
<script
src=
"sparray.js"
></script>
<script
type =
"text/javascript"
src=
"source.js"
></script>
<script
src=
"interp.js"
></script>
<script
src=
"generator/tests/log_source.js"
></script>
<script
src=
"generator/tests/calc.log.js"
></script>
<!--<script src="generator/tests/log_source.js"></script>-->
<style>
.source_div
{
...
...
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