nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into polymorphic_extern_classes
[nit.git]
/
contrib
/
pep8analysis
/
src
/
pep8analysis_web.nit
diff --git
a/contrib/pep8analysis/src/pep8analysis_web.nit
b/contrib/pep8analysis/src/pep8analysis_web.nit
index
8b87b3e
..
30c0849
100644
(file)
--- a/
contrib/pep8analysis/src/pep8analysis_web.nit
+++ b/
contrib/pep8analysis/src/pep8analysis_web.nit
@@
-19,7
+19,10
@@
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
-module pep8analysis_web
+module pep8analysis_web is
+ cpp_compiler_option("--std=c++11 --bind")
+ c_linker_option("--bind")
+end
import emscripten
import emscripten
@@
-28,14
+31,29
@@
import ast
import model
import cfg
import flow_analysis
import model
import cfg
import flow_analysis
+intrude import standard::stream
+
+in "C++" `{
+ #include <bind.h>
+
+ using namespace emscripten;
+
+ EMSCRIPTEN_BINDINGS(my_module) {
+ function("run_analysis", &NativeString_run_analysis, allow_raw_pointers());
+ }
+`}
redef class AnalysisManager
fun run(src: String)
do
redef class AnalysisManager
fun run(src: String)
do
+ sys.suggest_garbage_collection
+
var stream = new StringIStream(src)
var ast = build_ast("web", stream)
var stream = new StringIStream(src)
var ast = build_ast("web", stream)
- assert ast != null
+ if ast == null then return
+
+ sys.suggest_garbage_collection
if failed then exit 1
if failed then exit 1
@@
-45,29
+63,39
@@
redef class AnalysisManager
if model.lines.is_empty then
fatal_error( ast, "This programs appears empty" )
if model.lines.is_empty then
fatal_error( ast, "This programs appears empty" )
- exit 1
+ return
end
end
+ sys.suggest_garbage_collection
+
# Create CFG
var cfg = build_cfg(model)
if failed then exit 1
# Run analyses
# Create CFG
var cfg = build_cfg(model)
if failed then exit 1
# Run analyses
+ sys.suggest_garbage_collection
+
## Reaching defs
do_reaching_defs_analysis(cfg)
## Reaching defs
do_reaching_defs_analysis(cfg)
+ sys.suggest_garbage_collection
+
## Range
do_range_analysis(ast, cfg)
## Range
do_range_analysis(ast, cfg)
+ sys.suggest_garbage_collection
+
## Types
do_types_analysis(ast, cfg)
## Types
do_types_analysis(ast, cfg)
+ sys.suggest_garbage_collection
+
print_notes
if notes.is_empty then print "Success: Nothing wrong detected"
var of = new StringOStream
print_notes
if notes.is_empty then print "Success: Nothing wrong detected"
var of = new StringOStream
- cfg.print_dot(of, true)
+ cfg.print_dot(of, false)
of.close
show_graph(of.to_s)
of.close
show_graph(of.to_s)
@@
-88,8
+116,11
@@
class StringIStream
redef var end_reached: Bool = false
end
redef var end_reached: Bool = false
end
-redef class Object
- redef fun manager do return once new AnalysisManager
+redef class NativeString
+ fun run_analysis do manager.run to_s
end
end
-manager.run args.first
+fun dummy_set_callbacks import NativeString.run_analysis in "C++" `{
+`}
+
+dummy_set_callbacks