Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
125
Issues
125
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
5f008456
Commit
5f008456
authored
Apr 26, 2014
by
MARCHE Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bigInt: javascript
parent
bd050c46
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
194 additions
and
2 deletions
+194
-2
.gitignore
.gitignore
+4
-2
examples/in_progress/bigInt/Makefile
examples/in_progress/bigInt/Makefile
+83
-0
examples/in_progress/bigInt/index.html
examples/in_progress/bigInt/index.html
+13
-0
examples/in_progress/bigInt/jsmain.ml
examples/in_progress/bigInt/jsmain.ml
+70
-0
examples/in_progress/bigInt/main.ml
examples/in_progress/bigInt/main.ml
+24
-0
No files found.
.gitignore
View file @
5f008456
...
...
@@ -222,8 +222,10 @@ pvsbin/
/examples/euler001/*__*.ml
/examples/sudoku/*__*.ml
/examples/defunctionalization/*__*.ml
examples/vstte12_combinators/jsmain.js
examples/vstte12_combinators/*__*.ml
/examples/vstte12_combinators/jsmain.js
/examples/vstte12_combinators/*__*.ml
/examples/in_progress/bigInt/jsmain.js
/examples/in_progress/bigInt/*__*.ml
# modules
...
...
examples/in_progress/bigInt/Makefile
0 → 100644
View file @
5f008456
BENCH
?=
no
ifeq
($(BENCH),yes)
WHY3
=
../../bin/why3
WHY3SHARE
=
../../share
else
ifeq
($(BINDIR),)
WHY3
=
why3
else
WHY3
=
$(BINDIR)
/why3
endif
WHY3SHARE
=
$(
shell
$(WHY3)
--print-datadir
)
endif
include
$(WHY3SHARE)/Makefile.config
ifeq
($(BENCH),yes)
INCLUDE
+=
-I
../../lib/why3
endif
MAIN
=
main
GEN
=
bigInt__N
OBJ
=
$(GEN)
GENML
=
$(
addsuffix
.ml,
$(GEN)
)
ML
=
$(
addsuffix
.ml,
$(OBJ)
)
CMO
=
$(
addsuffix
.cmo,
$(OBJ)
)
CMX
=
$(
addsuffix
.cmx,
$(OBJ)
)
OCAMLOPT
=
ocamlopt
-noassert
-inline
1000
all
:
$(MAIN).$(OCAMLBEST)
extract
:
$(ML)
$(MAIN).byte
:
$(CMO) $(MAIN).cmo
ocamlc
$(INCLUDE)
$(BIGINTLIB)
.cma why3extract.cma
-o
$@
$^
$(MAIN).opt
:
$(CMX) $(MAIN).cmx
$(OCAMLOPT)
$(INCLUDE)
$(BIGINTLIB)
.cmxa why3extract.cmxa
-o
$@
$^
$(MAIN).cmx
:
$(CMX)
$(ML)
:
../bigInt.mlw
$(WHY3)
-E
ocaml32
$<
-o
.
%.cmx
:
%.ml
$(OCAMLOPT)
$(INCLUDE)
-annot
-c
$<
%.cmo
:
%.ml
ocamlc
$(INCLUDE)
-annot
-c
$<
%.cmi
:
%.mli
ocamlc
$(INCLUDE)
-annot
-c
$<
clean
::
rm
-f
$(GENML)
*
.cm[xio]
*
.o
*
.annot
$(MAIN)
.opt
$(MAIN)
.byte
rm
-f
why3__
*
.ml
*
bigInt__
*
.ml
*
int__
*
.ml
*
# javascript
JSMAIN
=
jsmain
JSOCAMLC
=
ocamlfind ocamlc
-package
js_of_ocaml
-package
js_of_ocaml.syntax
\
-syntax
camlp4o
$(JSMAIN).js
:
$(JSMAIN).byte
js_of_ocaml
-pretty
-noinline
$(JSMAIN)
.byte
$(JSMAIN).byte
:
$(ML) jsmain.ml
$(JSOCAMLC)
$(INCLUDE)
-o
$@
-linkpkg
$^
%.cmo
:
%.ml
$(JSOCAMLC)
$(INCLUDE)
-annot
-c
$<
%.cmi
:
%.mli
$(JSOCAMLC)
$(INCLUDE)
-annot
-c
$<
examples/in_progress/bigInt/index.html
0 → 100644
View file @
5f008456
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title>
Javascript test for bigInt
</title>
</head>
<body
id=
"test"
>
<h1>
Javascript test for bigInt
</h1>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<script
type=
"text/javascript"
src=
"jsmain.js"
></script>
</body>
</html>
examples/in_progress/bigInt/jsmain.ml
0 → 100644
View file @
5f008456
(* computation part *)
open
BigInt__N
let
compute_result
text
=
try
let
t
=
from_small_int
(
int_of_string
text
)
in
let
a
=
add
t
t
in
let
a
=
add
a
t
in
for
i
=
0
to
Array
.
length
a
.
digits
-
1
do
Format
.
fprintf
Format
.
str_formatter
"a[%d] = %d@."
i
a
.
digits
.
(
i
)
done
;
Format
.
flush_str_formatter
()
with
_
->
"error"
(* HTML rendering *)
module
Html
=
Dom_html
let
node
x
=
(
x
:
#
Dom
.
node
Js
.
t
:>
Dom
.
node
Js
.
t
)
let
(
<|
)
e
l
=
List
.
iter
(
fun
c
->
Dom
.
appendChild
e
c
)
l
;
node
e
let
html_of_string
(
d
:
Html
.
document
Js
.
t
)
(
s
:
string
)
=
d
##
createElement
(
Js
.
string
"p"
)
<|
[
node
(
d
##
createTextNode
(
Js
.
string
s
))]
let
replace_child
p
n
=
Js
.
Opt
.
iter
(
p
##
firstChild
)
(
fun
c
->
Dom
.
removeChild
p
c
);
Dom
.
appendChild
p
n
let
onload
(
_event
:
#
Html
.
event
Js
.
t
)
:
bool
Js
.
t
=
let
d
=
Html
.
document
in
let
body
=
Js
.
Opt
.
get
(
d
##
getElementById
(
Js
.
string
"test"
))
(
fun
()
->
assert
false
)
in
let
textbox
=
Html
.
createTextarea
d
in
textbox
##
rows
<-
20
;
textbox
##
cols
<-
100
;
let
preview
=
Html
.
createDiv
d
in
preview
##
style
##
border
<-
Js
.
string
"1px black"
;
preview
##
style
##
padding
<-
Js
.
string
"5px"
;
Dom
.
appendChild
body
textbox
;
Dom
.
appendChild
body
(
Html
.
createBr
d
);
Dom
.
appendChild
body
preview
;
let
rec
dyn_preview
old_text
n
=
let
text
=
Js
.
to_string
(
textbox
##
value
)
in
let
n
=
if
text
<>
old_text
then
begin
begin
try
let
rendered
=
html_of_string
d
(
compute_result
text
)
in
replace_child
preview
rendered
with
_
->
()
end
;
20
end
else
max
0
(
n
-
1
)
in
Lwt
.
bind
(
Lwt_js
.
sleep
(
if
n
=
0
then
0
.
5
else
0
.
1
))
(
fun
()
->
dyn_preview
text
n
)
in
let
(
_
:
'
a
Lwt
.
t
)
=
dyn_preview
""
0
in
Js
.
_false
let
(
_
:
unit
)
=
Html
.
window
##
onload
<-
Html
.
handler
onload
examples/in_progress/bigInt/main.ml
0 → 100644
View file @
5f008456
open
Why3extract
open
Format
let
usage
()
=
eprintf
"Usage: %s <decimal number>@."
Sys
.
argv
.
(
0
);
exit
2
let
input
=
if
Array
.
length
Sys
.
argv
<>
2
then
usage
()
;
Sys
.
argv
.
(
1
)
open
BigInt__N
let
input_num
=
try
from_small_int
(
int_of_string
input
)
with
_
->
usage
()
let
()
=
let
a
=
BigInt__N
.
add
input_num
input_num
in
let
a
=
BigInt__N
.
add
a
input_num
in
for
i
=
0
to
Array
.
length
a
.
digits
-
1
do
printf
"a[%d] = %d@."
i
a
.
digits
.
(
i
)
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment