nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
benches/markdowm: adds README
[nit.git]
/
src
/
frontend
/
cached.nit
diff --git
a/src/frontend/cached.nit
b/src/frontend/cached.nit
index
830ff66
..
f331b1d
100644
(file)
--- a/
src/frontend/cached.nit
+++ b/
src/frontend/cached.nit
@@
-14,23
+14,24
@@
# Implementation of the method-related annotation `cached`
#
# Implementation of the method-related annotation `cached`
#
-# Note this module can be used as a reference on how to implements
-# complex annotation that modify both the model and the AST of a Nit program
+# The cached annotation is deprecated, use the `lazy` annotation instead.
module cached
import modelize
private import parser_util
import simple_misc_analysis
private import annotation
module cached
import modelize
private import parser_util
import simple_misc_analysis
private import annotation
+intrude import modelize::modelize_property
redef class ToolContext
redef class ToolContext
+ # Process the `cached` annotation on methods
var cached_phase: Phase = new CachedPhase(self, [modelize_property_phase])
end
private class CachedPhase
super Phase
var cached_phase: Phase = new CachedPhase(self, [modelize_property_phase])
end
private class CachedPhase
super Phase
- init(toolcontext, depends)
+ init
do
# FIXME The phase has to be executed just after `modelize_property_phase`
# But there is no simple way to express this
do
# FIXME The phase has to be executed just after `modelize_property_phase`
# But there is no simple way to express this
@@
-143,6
+144,10
@@
private class CachedPhase
# Sanity checks
assert nclassdef.mclassdef == mclassdef
# Sanity checks
assert nclassdef.mclassdef == mclassdef
+ if n isa AAttrPropdef then
+ n.has_value = n.n_expr != null or n.n_block != null
+ end
+
# Required so that propdef are visited in visitors
if not nclassdef.n_propdefs.has(n) then nclassdef.n_propdefs.add(n)
end
# Required so that propdef are visited in visitors
if not nclassdef.n_propdefs.has(n) then nclassdef.n_propdefs.add(n)
end