nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ni_nitdoc: added fast copy past utility to signatures.
[nit.git]
/
src
/
phase.nit
diff --git
a/src/phase.nit
b/src/phase.nit
index
667ba43
..
70d3a71
100644
(file)
--- a/
src/phase.nit
+++ b/
src/phase.nit
@@
-27,14
+27,21
@@
redef class ToolContext
# it is often simpler to use the constructor in `Phase`
var phases = new POSet[Phase]
# it is often simpler to use the constructor in `Phase`
var phases = new POSet[Phase]
+ fun phases_list: Sequence[Phase]
+ do
+ var phases = self.phases.to_a
+ self.phases.sort(phases)
+ return phases
+ end
+
# Run all registered phases on a set of modules
fun run_phases(nmodules: Collection[AModule])
do
var time0 = get_time
self.info("*** SEMANTIC ANALYSIS ***", 1)
#phases.show_dot
# Run all registered phases on a set of modules
fun run_phases(nmodules: Collection[AModule])
do
var time0 = get_time
self.info("*** SEMANTIC ANALYSIS ***", 1)
#phases.show_dot
- var phases = self.phases.to_a
- self.phases.sort(phases)
+
+ var phases = phases_list
for phase in phases do
self.info(" registered phases: {phase.class_name}", 2)
for phase in phases do
self.info(" registered phases: {phase.class_name}", 2)
@@
-63,6
+70,12
@@
redef class ToolContext
self.check_errors
break
end
self.check_errors
break
end
+ var v = new AnnotationPhaseVisitor(phase)
+ v.enter_visit(nmodule)
+ if errcount != self.error_count then
+ self.check_errors
+ break
+ end
end
self.check_errors
end
end
self.check_errors
end
@@
-72,9
+85,22
@@
redef class ToolContext
end
end
end
end
+private class AnnotationPhaseVisitor
+ super Visitor
+
+ var phase: Phase
+
+ init(phase: Phase) do self.phase = phase
+
+ redef fun visit(n)
+ do
+ n.visit_all(self)
+ if n isa AAnnotation then phase.process_annotated_node(n.parent.parent.as(not null), n)
+ end
+end
+
# Abstraction of steps in the analysis/processing of Nit programs
# Abstraction of steps in the analysis/processing of Nit programs
-# Specific phases should implements either `process_nmodule` or
-# `process_npropdef`.
+# Specific phases should implements one of the `process_*` method
abstract class Phase
# The toolcontext instance attached to the phase
var toolcontext: ToolContext
abstract class Phase
# The toolcontext instance attached to the phase
var toolcontext: ToolContext
@@
-102,4
+128,9
@@
abstract class Phase
# Note that the order of the visit is the one of the file
# @toimplement
fun process_npropdef(npropdef: APropdef) do end
# Note that the order of the visit is the one of the file
# @toimplement
fun process_npropdef(npropdef: APropdef) do end
+
+ # Specific actions to execute on annotated nodes
+ # Note that the order of the visit is the one of the file
+ # @toimplement
+ fun process_annotated_node(node: ANode, nat: AAnnotation) do end
end
end