0d9597edaff4e07b66d5763a8bf990ae24e5845a
[nit.git] / src / syntax / syntax_base.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2008 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Common syntax structures for syntax analysis of NIT AST.
18 package syntax_base
19
20 import parser
21 import mmloader
22
23 # Concrete NIT source module
24 class MMSrcModule
25 super MMModule
26 # A source module can locate AST nodes of related MM entities
27 # Once a source module AST is no more needed, _nodes is set to null
28 # See ToolContext::keep_ast property in syntax.nit for details
29 var _nodes: nullable HashMap[Object, nullable ANode] = new HashMap[Object, nullable ANode]
30
31 # Release the AST
32 fun clear_ast do _nodes = null
33
34 # The related AST node
35 fun node: AModule do return nodes(self).as(AModule)
36
37 # Concrete NIT source local classs by name
38 readable var _src_local_classes: Map[Symbol, MMSrcLocalClass]
39
40 init(c: MMContext, source: AModule, dir: MMDirectory, name: Symbol, loc: Location)
41 do
42 super(name, dir, c, loc)
43 nodes(self) = source
44 _src_local_classes = new HashMap[Symbol, MMSrcLocalClass]
45 end
46
47 redef fun nodes(o: Object): nullable ANode
48 do
49 if _nodes != null and _nodes.has_key(o) then return _nodes[o] else return null
50 end
51 redef fun nodes=(o: Object, n: nullable ANode)
52 do
53 assert not _nodes.has_key(o)
54 _nodes[o] = n
55 end
56 end
57
58 redef class MMModule
59 # The AST node of some entity
60 private fun nodes(o: Object): nullable ANode do return null
61 # The AST node of some entity
62 private fun nodes=(o: Object, n: nullable ANode) do abort
63 end
64
65 redef class MMGlobalClass
66 # Check that a module can access a class
67 fun check_visibility(v: AbsSyntaxVisitor, n: ANode, cm: MMSrcModule): Bool do
68 var pm = intro.mmmodule
69 assert pm isa MMSrcModule
70 var vpm = cm.visibility_for(pm)
71 if vpm == 3 then
72 return true
73 else if vpm == 0 then
74 v.error(n, "Visibility error: Class {self} comes from the hidden module {cm}.") # TODO: should not occur
75 return false
76 else if visibility_level >= 3 then
77 v.error(n, "Visibility error: Class {self} is private.")
78 return false
79 end
80 return true
81 end
82 end
83
84 # Concrete NIT source local classes
85 class MMSrcLocalClass
86 super MMConcreteClass
87 # The first related AST node (if any)
88 fun node: nullable AClassdef do return mmmodule.nodes(self).as(nullable AClassdef)
89
90 # Concrete NIT source generic formal parameter by name
91 readable var _formal_dict: Map[Symbol, MMTypeFormalParameter] = new HashMap[Symbol, MMTypeFormalParameter]
92
93 # Concrete NIT source properties by name
94 readable var _src_local_properties: Map[Symbol, MMLocalProperty]
95
96 init(mod: MMSrcModule, n: Symbol, cla: nullable AClassdef, a: Int)
97 do
98 super(mod, n, a)
99 mod.nodes(self) = cla
100 _src_local_properties = new HashMap[Symbol, MMLocalProperty]
101 end
102 end
103
104 redef class MMGlobalProperty
105 # Check that a module can access a property
106 fun check_visibility(v: AbsSyntaxVisitor, n: ANode, cm: MMSrcModule, allows_protected: Bool): Bool do
107 var pm = local_class.mmmodule
108 assert pm isa MMSrcModule
109 var vpm = cm.visibility_for(pm)
110 if vpm == 3 then
111 return true
112 else if vpm == 0 then
113 # TODO: should not occurs
114 v.error(n, "Visibility error: Property {self} comes from the hidden module {cm}.")
115 return false
116 else if visibility_level >= 3 then
117 v.error(n, "Visibility error: Property {self} is private.")
118 return false
119 else if visibility_level >= 2 and not allows_protected then
120 v.error(n, "Visibility error: Property {self} is protected and can only acceded by self.")
121 return false
122 end
123 return true
124 end
125 end
126
127 redef class MMLocalProperty
128 # The attached node (if any)
129 fun node: nullable ANode do return null
130
131 # Is the concrete method defined as init
132 fun is_init: Bool do return false
133 end
134
135 # Concrete NIT source attribute
136 class MMSrcAttribute
137 super MMAttribute
138 redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
139 init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
140 do
141 super(name, cla)
142 cla.mmmodule.nodes(self) = n
143 end
144 end
145
146 # Concrete NIT source method
147 class MMSrcMethod
148 super MMMethod
149 redef fun is_intern do return false
150 redef fun is_extern do return false
151 redef fun is_abstract do return false
152 redef fun extern_name do return null
153 end
154
155 # Concrete NIT source method for an automatic accesor
156 class MMAttrImplementationMethod
157 super MMSrcMethod
158 redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
159 init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
160 do
161 super(name, cla)
162 cla.mmmodule.nodes(self) = n
163 end
164 end
165
166 # Concrete NIT source method for an automatic read accesor
167 class MMReadImplementationMethod
168 super MMAttrImplementationMethod
169 init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
170 do
171 super(name, cla, n)
172 end
173 end
174
175 # Concrete NIT source method for an automatic write accesor
176 class MMWriteImplementationMethod
177 super MMAttrImplementationMethod
178 init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
179 do
180 super(name, cla, n)
181 end
182 end
183
184 # Concrete NIT source method for an explicit method
185 class MMMethSrcMethod
186 super MMSrcMethod
187 redef readable var _is_init: Bool
188 redef readable var _is_intern: Bool
189 redef readable var _is_extern: Bool
190 redef readable var _is_abstract: Bool
191 redef readable writable var _extern_name: nullable String # Will be computed during MMBuilder
192 redef readable var _explicit_casts : Set[MMImportedCast] = new HashSet[MMImportedCast]
193 redef readable var _explicit_imports : Set[MMExplicitImport] = new HashSet[MMExplicitImport]
194 redef fun node: nullable AMethPropdef do return mmmodule.nodes(self).as(nullable AMethPropdef)
195 init(name: Symbol, cla: MMLocalClass, n: nullable AMethPropdef)
196 do
197 super(name, cla)
198 cla.mmmodule.nodes(self) = n
199 _is_init = node isa AInitPropdef
200 _is_intern = node isa AInternMethPropdef
201 _is_extern = node isa AExternPropdef
202 _is_abstract = node isa ADeferredMethPropdef
203 _extern_name = null
204 end
205 end
206
207 # Concrete NIT source virtual type
208 class MMSrcTypeProperty
209 super MMLocalProperty
210 super MMTypeProperty
211 init(name: Symbol, cla: MMLocalClass, n: ATypePropdef)
212 do
213 super(name, cla)
214 end
215 end
216
217 # Concrete NIT implicit constructor
218 class MMImplicitInit
219 super MMMethSrcMethod
220 fun super_init: nullable MMLocalProperty is abstract
221 redef fun is_init do return true
222 readable var _unassigned_attributes: Array[MMSrcAttribute]
223 readable var _super_inits: Array[MMLocalProperty]
224 init(cla: MMLocalClass, unassigned_attributes: Array[MMSrcAttribute], super_inits: Array[MMLocalProperty])
225 do
226 super(once "init".to_symbol, cla, null)
227 _unassigned_attributes = unassigned_attributes
228 _super_inits = super_inits
229 end
230 end
231
232 # Local variables
233 abstract class Variable
234 # Name of the variable
235 readable var _name: Symbol
236
237 # Declaration AST node
238 readable var _decl: nullable ANode
239
240 # Static type
241 readable writable var _stype: nullable MMType
242
243 redef fun to_s do return _name.to_s
244
245 fun kind: String is abstract
246
247 init(n: Symbol, d: nullable ANode)
248 do
249 _name = n
250 _decl = d
251 end
252 end
253
254 # Variable declared with 'var'
255 class VarVariable
256 super Variable
257 redef fun kind do return once "variable"
258 init(n: Symbol, d: ANode) do super
259 end
260
261 # Parameter of method (declared in signature)
262 class ParamVariable
263 super Variable
264 redef fun kind do return once "parameter"
265 init(n: Symbol, d: nullable ANode) do super
266 end
267
268 # Automatic variable (like in the 'for' statement)
269 class AutoVariable
270 super Variable
271 redef fun kind do return once "automatic variable"
272 init(n: Symbol, d: ANode) do super
273 end
274
275 # False variable corresponding to closures declared in signatures
276 # Lives in the same namespace than variables
277 class ClosureVariable
278 super Variable
279 redef fun kind do return once "closure"
280
281 # The signature of the closure
282 readable var _closure: MMClosure
283
284 init(n: Symbol, d: ANode, c: MMClosure)
285 do
286 super(n, d)
287 _closure = c
288 end
289 end
290
291 ###############################################################################
292
293 # Visitor used during the syntax analysis
294 class AbsSyntaxVisitor
295 super Visitor
296 fun get_type_by_name(clsname: Symbol): MMType
297 do
298 if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
299 var cls = _mmmodule.class_by_name(clsname)
300 return cls.get_type
301 end
302
303 fun get_instantiated_type_by_name(clsname: Symbol, vtype: Array[MMType]): MMType
304 do
305 if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
306 var cls = _mmmodule.class_by_name(clsname)
307 return cls.get_instantiate_type(vtype)
308 end
309
310 # The root type Object
311 fun type_object: MMType
312 do
313 return get_type_by_name(once ("Object".to_symbol))
314 end
315
316 # The primitive type Bool
317 fun type_bool: MMType
318 do
319 return get_type_by_name(once ("Bool".to_symbol))
320 end
321
322 # The primitive type Int
323 fun type_int: MMType
324 do
325 return get_type_by_name(once ("Int".to_symbol))
326 end
327
328 # The primitive type Float
329 fun type_float: MMType
330 do
331 return get_type_by_name(once ("Float".to_symbol))
332 end
333
334 # The primitive type Char
335 fun type_char: MMType
336 do
337 return get_type_by_name(once ("Char".to_symbol))
338 end
339
340 # The primitive type String
341 fun type_string: MMType
342 do
343 return get_type_by_name(once ("String".to_symbol))
344 end
345
346 # The primitive type NativeString
347 fun type_nativestring: MMType
348 do
349 return get_type_by_name(once ("NativeString".to_symbol))
350 end
351
352 # The primitive type Array[?]
353 fun type_array(stype: MMType): MMType
354 do
355 return get_instantiated_type_by_name(once ("Array".to_symbol), [stype])
356 end
357
358 # The primitive type Discrete
359 fun type_discrete: MMType
360 do
361 return get_type_by_name(once ("Discrete".to_symbol))
362 end
363
364 # The primitive type Range[?]
365 fun type_range(stype: MMType): MMType
366 do
367 return get_instantiated_type_by_name(once ("Range".to_symbol), [stype])
368 end
369
370 # The primitive type of null
371 fun type_none: MMType
372 do
373 return _mmmodule.type_none
374 end
375
376 fun get_method(recv: MMType, name: Symbol): MMMethod
377 do
378 if not recv.local_class.has_global_property_by_name(name) then
379 fatal_error(current_node, "Fatal Error: {recv} must have a property named {name}.")
380 end
381 return recv.local_class.select_method(name)
382 end
383
384 # The current module
385 readable var _mmmodule: MMSrcModule
386
387 # The current class
388 fun local_class: MMSrcLocalClass do return _local_class.as(not null)
389 writable var _local_class: nullable MMSrcLocalClass
390
391 # The current property
392 fun local_property: MMLocalProperty do return _local_property.as(not null)
393 writable var _local_property: nullable MMLocalProperty
394
395 # The current tool configuration/status
396 readable var _tc: ToolContext
397
398 # Display an error for a given syntax node
399 fun error(n: nullable ANode, s: String)
400 do
401 _tc.error(if n == null then null else n.hot_location, s)
402 end
403
404 # Add an error, show errors and quit
405 fun fatal_error(n: nullable ANode, s: String)
406 do
407 _tc.fatal_error(if n == null then null else n.hot_location, s)
408 end
409
410 # Display a warning for a given syntax node
411 fun warning(n: nullable ANode, s: String)
412 do
413 _tc.warning(if n == null then null else n.hot_location, s)
414 end
415
416 # Check conformity and display error
417 fun check_conform(n: ANode, subtype: nullable MMType, stype: nullable MMType): Bool
418 do
419 if stype == null or subtype == null then
420 return false
421 end
422 if subtype < stype then
423 return true
424 end
425 error(n, "Type error: expected {stype}, got {subtype}")
426 return false
427 end
428
429 # Check that an expression has a static type and that
430 # Display an error and return false if n is a statement
431 # Require that the static type of n is known
432 fun check_expr(n: AExpr): Bool
433 do
434 if not n.is_typed then
435 if tc.error_count == 0 then
436 print("{n.location} not typed but not error")
437 abort
438 end
439 # An error occured in a sub node,
440 # sillently cascade fail
441 return false
442 else if n.is_statement then
443 error(n, "Type error: expected expression.")
444 return false
445 end
446 return true
447 end
448
449 # Combine check_conform and check_expr
450 fun check_conform_expr(n: AExpr, stype: nullable MMType): Bool
451 do
452 if stype == null then return false
453 if check_expr(n) then return check_conform(n, n.stype, stype) else return false
454 end
455
456 # Check conformance between multiple expressions and a static type
457 # Conformance is granted if among them there is a most general type
458 # Return the most general type if a conformance is found
459 # Display an error and return null if no conformance is found
460 # The only allowed combinaison is with the nullable marker
461 # @param stype is a possible additional type (without node)
462 # Examples:
463 # Int, Int, Object => return Object
464 # Int, Float => display error, return null
465 # nullable Int, Object => return nullable Object
466 fun check_conform_multiexpr(stype: nullable MMType, nodes: Collection[AExpr]): nullable MMType
467 do
468 var node: nullable AExpr = null # candidate node
469 for n in nodes do
470 if not check_expr(n) then return null
471 var ntype = n.stype
472 if stype != null and stype.is_nullable != ntype.is_nullable then
473 # nullable combinaison: if one of them is nulable, considers that both are
474 stype = stype.as_nullable
475 ntype = ntype.as_nullable
476 end
477 if stype == null or stype < ntype then
478 stype = ntype
479 node = n
480 end
481 end
482 assert stype != null
483 for n in nodes do
484 if not n.stype < stype then
485 if node == null then
486 error(n, "Type error: no most general type. Got {n.stype} and {stype}.")
487 else
488 error(n, "Type error: no most general type. Got {n.stype} and {stype} at {node.location.relative_to(n.location)}.")
489 end
490 return null
491 end
492 end
493 return stype
494 end
495
496 protected init(tc: ToolContext, mmmodule: MMSrcModule)
497 do
498 _tc = tc
499 _mmmodule = mmmodule
500 end
501 end
502
503 ###############################################################################
504
505 redef class ANode
506 protected fun accept_abs_syntax_visitor(v: AbsSyntaxVisitor) do visit_all(v)
507 end
508
509 redef class Token
510 var _symbol_cache: nullable Symbol
511
512 # Symbol associated with the text
513 # Lazily computed
514 fun to_symbol: Symbol
515 do
516 var s = _symbol_cache
517 if s == null then
518 s = text.to_symbol
519 _symbol_cache = s
520 end
521 return s
522 end
523 end
524
525 redef class AClassdef
526 # Associated class (MM entity)
527 fun local_class: MMSrcLocalClass is abstract
528
529 # Next AClassdef of the same class (if any)
530 readable writable var _next_node: nullable AClassdef = null
531 end
532
533 redef class APropdef
534 # Associated 'self' variable
535 fun self_var: ParamVariable is abstract
536 end
537
538 redef class AAttrPropdef
539 # Associated attribute (MM entity)
540 fun prop: MMSrcAttribute is abstract
541
542 # Associated read accessor (MM entity)
543 fun readmethod: nullable MMSrcMethod is abstract
544
545 # Associated write accessor (MM entity)
546 fun writemethod: nullable MMSrcMethod is abstract
547 end
548
549 redef class AConcreteInitPropdef
550 readable var _super_init_calls: Array[MMMethod] = new Array[MMMethod]
551 readable var _explicit_super_init_calls: Array[MMMethod] = new Array[MMMethod]
552 end
553
554 redef class AMethPropdef
555 # Associated method (MM entity)
556 fun method: MMMethSrcMethod is abstract
557 end
558
559 redef class ATypePropdef
560 # Associated formal type (MM entity)
561 fun prop: MMSrcTypeProperty is abstract
562 end
563
564 redef class AParam
565 # Position in the signature
566 fun position: Int is abstract
567
568 # Associated local variable
569 fun variable: ParamVariable is abstract
570 end
571
572 redef class AClosureDecl
573 # Position in the signature
574 fun position: Int is abstract
575
576 # Associated closure variable
577 fun variable: ClosureVariable is abstract
578 end
579
580 redef class AType
581 # Is the node correcly typed
582 # Return false if typed was not yet computed or
583 # if an error occured during the typing computation
584 fun is_typed: Bool is abstract
585
586 # Return corresponding static type. (require is_typed)
587 fun stype: MMType is abstract
588
589 var _stype_cache: nullable MMType = null
590 var _stype_cached: Bool = false
591
592 # Retrieve the local class corresponding to the type.
593 # Display an error and return null if there is no class
594 # Display an error and return null if the type is not class based (formal one)
595 fun get_local_class(v: AbsSyntaxVisitor): nullable MMLocalClass
596 do
597 var name = n_id.to_symbol
598 var mod = v.mmmodule
599 var cla = v.local_class
600
601 if cla.formal_dict.has_key(name) or cla.has_global_property_by_name(name) then
602 v.error(n_id, "Type error: {name} is a formal type")
603 _stype_cached = true
604 return null
605 end
606
607 if not mod.has_global_class_named(name) then
608 v.error(n_id, "Type error: class {name} not found in module {mod}.")
609 _stype_cached = true
610 return null
611 end
612
613 var local_class = mod.class_by_name(name)
614 local_class.global.check_visibility(v, self, mod)
615 return local_class
616 end
617
618 # Retrieve corresponding static type.
619 # Display an error and return null if there is a problem
620 # But do not performs any subtype check.
621 # get_unchecked_stype should be called to check that the static type is fully valid
622 fun get_unchecked_stype(v: AbsSyntaxVisitor): nullable MMType
623 do
624 if _stype_cached then return _stype_cache
625 _stype_cached = true
626
627 var name = n_id.to_symbol
628 var mod = v.mmmodule
629 var cla = v.local_class
630 var t: nullable MMType
631
632 if cla.formal_dict.has_key(name) then
633 if n_types.length > 0 then
634 v.error(self, "Type error: formal type {name} cannot have formal parameters.")
635 return null
636 end
637 t = cla.formal_dict[name]
638 if n_kwnullable != null then t = t.as_nullable
639 _stype_cache = t
640 return t
641 end
642
643 if cla.has_global_property_by_name(name) then
644 if n_types.length > 0 then
645 v.error(self, "Type error: formal type {name} cannot have formal parameters.")
646 return null
647 end
648 t = cla.get_type.local_class.select_virtual_type(name).stype_for(cla.get_type)
649 if t == null then
650 v.error(self, "Type error: circular definition in formal type {name}.")
651 return null
652 end
653 if n_kwnullable != null then t = t.as_nullable
654 _stype_cache = t
655 return t
656 end
657
658 var local_class = get_local_class(v)
659 if local_class == null then return null
660
661 var arity = n_types.length
662 if local_class.arity != arity then
663 if arity == 0 then
664 v.error(self, "Type error: '{local_class}' is a generic class.")
665 else if local_class.arity == 0 then
666 v.error(self, "Type error: '{local_class}' is not a generic class.")
667 else
668 v.error(self, "Type error: '{local_class}' has {local_class.arity} parameters ({arity} are provided).")
669 end
670 return null
671 end
672
673 if arity > 0 then
674 var tab = new Array[MMType]
675 for p in n_types do
676 var t2 = p.get_unchecked_stype(v)
677 if t2 == null then return null
678 tab.add(t2)
679 end
680 t = local_class.get_instantiate_type(tab)
681 else
682 t = local_class.get_type
683 end
684 if n_kwnullable != null then t = t.as_nullable
685 _stype_cache = t
686 return t
687 end
688
689 # Retrieve corresponding static type.
690 # Display an error and return null if there is a problem
691 fun get_stype(v: AbsSyntaxVisitor): nullable MMType
692 do
693 var t = get_unchecked_stype(v)
694 if t == null then return null
695 if not t.is_valid then return null
696 check_conform(v)
697 return t
698 end
699
700 # Check that a static definition type is conform with regard to formal types
701 # Useful with get_unchecked_stype
702 # Remember that conformance check need that ancestors are totaly computed
703 fun check_conform(v: AbsSyntaxVisitor)
704 do
705 var st = get_unchecked_stype(v)
706 if st == null then return
707 var local_class = st.local_class
708 var arity = n_types.length
709 if arity > 0 then
710 for i in [0..arity[ do
711 var p = n_types[i]
712 var pt = p.get_stype(v)
713 var b = local_class.get_formal(i)
714 if not b.is_valid then return
715 var bt = b.bound
716 bt = bt.adapt_to(st) # We need to abapt because of F-genericity
717 v.check_conform(p, pt, bt)
718 end
719 end
720 end
721 end
722
723 redef class AExpr
724 # Is the expression node correcly typed
725 # Return false if typed was not yet computed or
726 # if an error occured during the typing computation
727 fun is_typed: Bool is abstract
728
729 # Is the expression node a statement? (ie has no return value)
730 # require: is_typed
731 fun is_statement: Bool is abstract
732
733 # The static type of the expression
734 # require: is_typed and not is_statement
735 fun stype: MMType is abstract
736 end
737
738 class AAbsAbsSendExpr
739 super AExpr
740 # The signature of the called property (require is_typed)
741 fun prop_signature: MMSignature is abstract
742
743 # The raw arguments used (without vararg transformation) (require is_typed)
744 fun raw_arguments: Array[AExpr] is abstract
745 end
746
747 class AAbsSendExpr
748 super AAbsAbsSendExpr
749 # The invoked method (require is_typed)
750 fun prop: MMMethod is abstract
751
752 # The return type (if any) (once computed)
753 fun return_type: nullable MMType is abstract
754 end
755
756 class ASuperInitCall
757 super AAbsSendExpr
758 end
759
760 redef class ASuperExpr
761 super ASuperInitCall
762 fun init_in_superclass: nullable MMMethod is abstract
763 end
764
765 redef class ANewExpr
766 super AAbsSendExpr
767 end
768
769 redef class ASendExpr
770 super ASuperInitCall
771 # Closure definitions
772 fun closure_defs: nullable Array[AClosureDef] is abstract
773 end
774
775 redef class AReassignFormExpr
776 # Method used through the reassigment operator (require is_typed)
777 fun assign_method: MMMethod is abstract
778 end
779
780 class ASendReassignExpr
781 super ASendExpr
782 super AReassignFormExpr
783 # The invoked method used to read (require is_typed)
784 # prop is the method used to write
785 fun read_prop: MMMethod is abstract
786 end
787
788 redef class ACallReassignExpr
789 super ASendReassignExpr
790 end
791
792 redef class ABraReassignExpr
793 super ASendReassignExpr
794 end
795
796 redef class AAttrFormExpr
797 # Attribute accessed (require is_typed)
798 fun prop: MMAttribute is abstract
799
800 # Attribute type of the acceded attribute (require is_typed)
801 fun attr_type: MMType is abstract
802 end
803
804 redef class ASuperstringExpr
805 fun atype: MMType is abstract
806 end
807
808 redef class AVardeclExpr
809 # Assiociated local variable
810 fun variable: VarVariable is abstract
811 #readable writable var _variable: nullable VarVariable
812 end
813
814 redef class AForExpr
815 # Associated automatic local variable
816 fun variables: Array[AutoVariable] is abstract
817 end
818
819 redef class ASelfExpr
820 # Associated local variable
821 fun variable: ParamVariable is abstract
822 end
823
824 redef class AVarFormExpr
825 # Associated local variable
826 fun variable: Variable is abstract
827 end
828
829 redef class AClosureCallExpr
830 super AAbsAbsSendExpr
831 # Associated closure variable
832 fun variable: ClosureVariable is abstract
833 end
834
835 redef class AClosureDef
836 # Associated closure
837 fun closure: MMClosure is abstract
838
839 # Automatic variables
840 readable writable var _variables: nullable Array[AutoVariable]
841 end
842
843 redef class AMethid
844 # Name of method
845 fun name: nullable Symbol is abstract
846 end