ni_nitdoc: added fast copy past utility to signatures.
[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 {pm}.") # 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 {pm}.")
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 abstract 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 abstract 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
205 if is_extern then
206 mmmodule.is_extern_hybrid = true
207 end
208 end
209 end
210
211 # Concrete NIT source virtual type
212 class MMSrcTypeProperty
213 super MMLocalProperty
214 super MMTypeProperty
215 init(name: Symbol, cla: MMLocalClass, n: ATypePropdef)
216 do
217 super(name, cla)
218 end
219 end
220
221 # Concrete NIT implicit constructor
222 class MMImplicitInit
223 super MMMethSrcMethod
224 fun super_init: nullable MMLocalProperty is abstract
225 redef fun is_init do return true
226 readable var _unassigned_attributes: Array[MMSrcAttribute]
227 readable var _super_inits: Array[MMLocalProperty]
228 init(cla: MMLocalClass, unassigned_attributes: Array[MMSrcAttribute], super_inits: Array[MMLocalProperty])
229 do
230 super(once "init".to_symbol, cla, null)
231 _unassigned_attributes = unassigned_attributes
232 _super_inits = super_inits
233 end
234 end
235
236 # Local variables
237 abstract class Variable
238 # Name of the variable
239 readable var _name: Symbol
240
241 # Declaration AST node
242 readable var _decl: nullable ANode
243
244 # Static type
245 readable writable var _stype: nullable MMType
246
247 redef fun to_s do return _name.to_s
248
249 fun kind: String is abstract
250
251 init(n: Symbol, d: nullable ANode)
252 do
253 _name = n
254 _decl = d
255 end
256 end
257
258 # Variable declared with 'var'
259 class VarVariable
260 super Variable
261 redef fun kind do return once "variable"
262 init(n: Symbol, d: ANode) do super
263 end
264
265 # Parameter of method (declared in signature)
266 class ParamVariable
267 super Variable
268 redef fun kind do return once "parameter"
269 init(n: Symbol, d: nullable ANode) do super
270 end
271
272 # Automatic variable (like in the 'for' statement)
273 class AutoVariable
274 super Variable
275 redef fun kind do return once "automatic variable"
276 init(n: Symbol, d: ANode) do super
277 end
278
279 # False variable corresponding to closures declared in signatures
280 # Lives in the same namespace than variables
281 class ClosureVariable
282 super Variable
283 redef fun kind do return once "closure"
284
285 # The signature of the closure
286 readable var _closure: MMClosure
287
288 init(n: Symbol, d: ANode, c: MMClosure)
289 do
290 super(n, d)
291 _closure = c
292 end
293 end
294
295 ###############################################################################
296
297 # Visitor used during the syntax analysis
298 abstract class AbsSyntaxVisitor
299 super Visitor
300 fun get_type_by_name(clsname: Symbol): MMType
301 do
302 if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
303 var cls = _mmmodule.class_by_name(clsname)
304 return cls.get_type
305 end
306
307 fun get_instantiated_type_by_name(clsname: Symbol, vtype: Array[MMType]): MMType
308 do
309 if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
310 var cls = _mmmodule.class_by_name(clsname)
311 return cls.get_instantiate_type(vtype)
312 end
313
314 # The root type Object
315 fun type_object: MMType
316 do
317 return get_type_by_name(once ("Object".to_symbol))
318 end
319
320 # The primitive type Bool
321 fun type_bool: MMType
322 do
323 return get_type_by_name(once ("Bool".to_symbol))
324 end
325
326 # The primitive type Int
327 fun type_int: MMType
328 do
329 return get_type_by_name(once ("Int".to_symbol))
330 end
331
332 # The primitive type Float
333 fun type_float: MMType
334 do
335 return get_type_by_name(once ("Float".to_symbol))
336 end
337
338 # The primitive type Char
339 fun type_char: MMType
340 do
341 return get_type_by_name(once ("Char".to_symbol))
342 end
343
344 # The primitive type String
345 fun type_string: MMType
346 do
347 return get_type_by_name(once ("String".to_symbol))
348 end
349
350 # The primitive type NativeString
351 fun type_nativestring: MMType
352 do
353 return get_type_by_name(once ("NativeString".to_symbol))
354 end
355
356 # The primitive type Array[?]
357 fun type_array(stype: MMType): MMType
358 do
359 return get_instantiated_type_by_name(once ("Array".to_symbol), [stype])
360 end
361
362 # The primitive type Discrete
363 fun type_discrete: MMType
364 do
365 return get_type_by_name(once ("Discrete".to_symbol))
366 end
367
368 # The primitive type Range[?]
369 fun type_range(stype: MMType): MMType
370 do
371 return get_instantiated_type_by_name(once ("Range".to_symbol), [stype])
372 end
373
374 # The primitive type of null
375 fun type_none: MMType
376 do
377 return _mmmodule.type_none
378 end
379
380 fun get_method(recv: MMType, name: Symbol): MMMethod
381 do
382 if not recv.local_class.has_global_property_by_name(name) then
383 fatal_error(current_node, "Fatal Error: {recv} must have a property named {name}.")
384 end
385 return recv.local_class.select_method(name)
386 end
387
388 # The current module
389 readable var _mmmodule: MMSrcModule
390
391 # The current class
392 fun local_class: MMSrcLocalClass do return _local_class.as(not null)
393 writable var _local_class: nullable MMSrcLocalClass
394
395 # The current property
396 fun local_property: MMLocalProperty do return _local_property.as(not null)
397 writable var _local_property: nullable MMLocalProperty
398
399 # The current tool configuration/status
400 readable var _tc: ToolContext
401
402 # Display an error for a given syntax node
403 fun error(n: nullable ANode, s: String)
404 do
405 _tc.error(if n == null then null else n.hot_location, s)
406 end
407
408 # Add an error, show errors and quit
409 fun fatal_error(n: nullable ANode, s: String)
410 do
411 _tc.fatal_error(if n == null then null else n.hot_location, s)
412 end
413
414 # Display a warning for a given syntax node
415 fun warning(n: nullable ANode, s: String)
416 do
417 _tc.warning(if n == null then null else n.hot_location, s)
418 end
419
420 # Check conformity and display error
421 fun check_conform(n: ANode, subtype: nullable MMType, stype: nullable MMType): Bool
422 do
423 if stype == null or subtype == null then
424 return false
425 end
426 if subtype < stype then
427 return true
428 end
429 error(n, "Type error: expected {stype}, got {subtype}")
430 return false
431 end
432
433 # Check that an expression has a static type and that
434 # Display an error and return false if n is a statement
435 # Require that the static type of n is known
436 fun check_expr(n: AExpr): Bool
437 do
438 if not n.is_typed then
439 if tc.error_count == 0 then
440 print("{n.location} not typed but not error")
441 abort
442 end
443 # An error occured in a sub node,
444 # sillently cascade fail
445 return false
446 else if n.is_statement then
447 error(n, "Type error: expected expression.")
448 return false
449 end
450 return true
451 end
452
453 # Combine check_conform and check_expr
454 fun check_conform_expr(n: AExpr, stype: nullable MMType): Bool
455 do
456 if stype == null then return false
457 if check_expr(n) then return check_conform(n, n.stype, stype) else return false
458 end
459
460 # Check conformance between multiple expressions and a static type
461 # Conformance is granted if among them there is a most general type
462 # Return the most general type if a conformance is found
463 # Display an error and return null if no conformance is found
464 # The only allowed combinaison is with the nullable marker
465 # @param stype is a possible additional type (without node)
466 # Examples:
467 # Int, Int, Object => return Object
468 # Int, Float => display error, return null
469 # nullable Int, Object => return nullable Object
470 fun check_conform_multiexpr(stype: nullable MMType, nodes: Collection[AExpr]): nullable MMType
471 do
472 var node: nullable AExpr = null # candidate node
473 for n in nodes do
474 if not check_expr(n) then return null
475 var ntype = n.stype
476 if stype != null and stype.is_nullable != ntype.is_nullable then
477 # nullable combinaison: if one of them is nulable, considers that both are
478 stype = stype.as_nullable
479 ntype = ntype.as_nullable
480 end
481 if stype == null or stype < ntype then
482 stype = ntype
483 node = n
484 end
485 end
486 assert stype != null
487 for n in nodes do
488 if not n.stype < stype then
489 if node == null then
490 error(n, "Type error: no most general type. Got {n.stype} and {stype}.")
491 else
492 error(n, "Type error: no most general type. Got {n.stype} and {stype} at {node.location.relative_to(n.location)}.")
493 end
494 return null
495 end
496 end
497 return stype
498 end
499
500 protected init(tc: ToolContext, mmmodule: MMSrcModule)
501 do
502 _tc = tc
503 _mmmodule = mmmodule
504 end
505 end
506
507 ###############################################################################
508
509 redef class ANode
510 protected fun accept_abs_syntax_visitor(v: AbsSyntaxVisitor) do visit_all(v)
511 end
512
513 redef class Token
514 var _symbol_cache: nullable Symbol
515
516 # Symbol associated with the text
517 # Lazily computed
518 fun to_symbol: Symbol
519 do
520 var s = _symbol_cache
521 if s == null then
522 s = text.to_symbol
523 _symbol_cache = s
524 end
525 return s
526 end
527 end
528
529 redef class AClassdef
530 # Associated class (MM entity)
531 fun local_class: MMSrcLocalClass is abstract
532
533 # Next AClassdef of the same class (if any)
534 readable writable var _next_node: nullable AClassdef = null
535 end
536
537 redef class APropdef
538 # Associated 'self' variable
539 fun self_var: ParamVariable is abstract
540 end
541
542 redef class AAttrPropdef
543 # Associated attribute (MM entity)
544 fun prop: MMSrcAttribute is abstract
545
546 # Associated read accessor (MM entity)
547 fun readmethod: nullable MMSrcMethod is abstract
548
549 # Associated write accessor (MM entity)
550 fun writemethod: nullable MMSrcMethod is abstract
551 end
552
553 redef class AConcreteInitPropdef
554 readable var _super_init_calls: Array[MMMethod] = new Array[MMMethod]
555 readable var _explicit_super_init_calls: Array[MMMethod] = new Array[MMMethod]
556 end
557
558 redef class AMethPropdef
559 # Associated method (MM entity)
560 fun method: MMMethSrcMethod is abstract
561 end
562
563 redef class ATypePropdef
564 # Associated formal type (MM entity)
565 fun prop: MMSrcTypeProperty is abstract
566 end
567
568 redef class AParam
569 # Position in the signature
570 fun position: Int is abstract
571
572 # Associated local variable
573 fun variable: ParamVariable is abstract
574 end
575
576 redef class AClosureDecl
577 # Position in the signature
578 fun position: Int is abstract
579
580 # Associated closure variable
581 fun variable: ClosureVariable is abstract
582 end
583
584 redef class AType
585 # Is the node correcly typed
586 # Return false if typed was not yet computed or
587 # if an error occured during the typing computation
588 fun is_typed: Bool is abstract
589
590 # Return corresponding static type. (require is_typed)
591 fun stype: MMType is abstract
592
593 var _stype_cache: nullable MMType = null
594 var _stype_cached: Bool = false
595
596 # Retrieve the local class corresponding to the type.
597 # Display an error and return null if there is no class
598 # Display an error and return null if the type is not class based (formal one)
599 fun get_local_class(v: AbsSyntaxVisitor): nullable MMLocalClass
600 do
601 var name = n_id.to_symbol
602 var mod = v.mmmodule
603 var cla = v.local_class
604
605 if cla.formal_dict.has_key(name) or cla.has_global_property_by_name(name) then
606 v.error(n_id, "Type error: {name} is a formal type")
607 _stype_cached = true
608 return null
609 end
610
611 if not mod.has_global_class_named(name) then
612 v.error(n_id, "Type error: class {name} not found in module {mod}.")
613 _stype_cached = true
614 return null
615 end
616
617 var local_class = mod.class_by_name(name)
618 local_class.global.check_visibility(v, self, mod)
619 return local_class
620 end
621
622 # Retrieve corresponding static type.
623 # Display an error and return null if there is a problem
624 # But do not performs any subtype check.
625 # get_unchecked_stype should be called to check that the static type is fully valid
626 fun get_unchecked_stype(v: AbsSyntaxVisitor): nullable MMType
627 do
628 if _stype_cached then return _stype_cache
629 _stype_cached = true
630
631 var name = n_id.to_symbol
632 var mod = v.mmmodule
633 var cla = v.local_class
634 var t: nullable MMType
635
636 if cla.formal_dict.has_key(name) then
637 if n_types.length > 0 then
638 v.error(self, "Type error: formal type {name} cannot have formal parameters.")
639 return null
640 end
641 t = cla.formal_dict[name]
642 if n_kwnullable != null then t = t.as_nullable
643 _stype_cache = t
644 return t
645 end
646
647 if cla.has_global_property_by_name(name) then
648 if n_types.length > 0 then
649 v.error(self, "Type error: formal type {name} cannot have formal parameters.")
650 return null
651 end
652 t = cla.get_type.local_class.select_virtual_type(name).stype_for(cla.get_type)
653 if t == null then
654 v.error(self, "Type error: circular definition in formal type {name}.")
655 return null
656 end
657 if n_kwnullable != null then t = t.as_nullable
658 _stype_cache = t
659 return t
660 end
661
662 var local_class = get_local_class(v)
663 if local_class == null then return null
664
665 var arity = n_types.length
666 if local_class.arity != arity then
667 if arity == 0 then
668 v.error(self, "Type error: '{local_class}' is a generic class.")
669 else if local_class.arity == 0 then
670 v.error(self, "Type error: '{local_class}' is not a generic class.")
671 else
672 v.error(self, "Type error: '{local_class}' has {local_class.arity} parameters ({arity} are provided).")
673 end
674 return null
675 end
676
677 if arity > 0 then
678 var tab = new Array[MMType]
679 for p in n_types do
680 var t2 = p.get_unchecked_stype(v)
681 if t2 == null then return null
682 tab.add(t2)
683 end
684 t = local_class.get_instantiate_type(tab)
685 else
686 t = local_class.get_type
687 end
688 if n_kwnullable != null then t = t.as_nullable
689 _stype_cache = t
690 return t
691 end
692
693 # Retrieve corresponding static type.
694 # Display an error and return null if there is a problem
695 fun get_stype(v: AbsSyntaxVisitor): nullable MMType
696 do
697 var t = get_unchecked_stype(v)
698 if t == null then return null
699 if not t.is_valid then return null
700 check_conform(v)
701 return t
702 end
703
704 # Check that a static definition type is conform with regard to formal types
705 # Useful with get_unchecked_stype
706 # Remember that conformance check need that ancestors are totaly computed
707 fun check_conform(v: AbsSyntaxVisitor)
708 do
709 var st = get_unchecked_stype(v)
710 if st == null then return
711 var local_class = st.local_class
712 var arity = n_types.length
713 if arity > 0 then
714 for i in [0..arity[ do
715 var p = n_types[i]
716 var pt = p.get_stype(v)
717 var b = local_class.get_formal(i)
718 if not b.is_valid then return
719 var bt = b.bound
720 bt = bt.adapt_to(st) # We need to abapt because of F-genericity
721 v.check_conform(p, pt, bt)
722 end
723 end
724 end
725 end
726
727 redef class AExpr
728 # Is the expression node correcly typed
729 # Return false if typed was not yet computed or
730 # if an error occured during the typing computation
731 fun is_typed: Bool is abstract
732
733 # Is the expression node a statement? (ie has no return value)
734 # require: is_typed
735 fun is_statement: Bool is abstract
736
737 # The static type of the expression
738 # require: is_typed and not is_statement
739 fun stype: MMType is abstract
740 end
741
742 abstract class AAbsAbsSendExpr
743 super AExpr
744 # The signature of the called property (require is_typed)
745 fun prop_signature: MMSignature is abstract
746
747 # The raw arguments used (without vararg transformation) (require is_typed)
748 fun raw_arguments: Array[AExpr] is abstract
749 end
750
751 abstract class AAbsSendExpr
752 super AAbsAbsSendExpr
753 # The invoked method (require is_typed)
754 fun prop: MMMethod is abstract
755
756 # The return type (if any) (once computed)
757 fun return_type: nullable MMType is abstract
758 end
759
760 abstract class ASuperInitCall
761 super AAbsSendExpr
762 end
763
764 redef class ASuperExpr
765 super ASuperInitCall
766 fun init_in_superclass: nullable MMMethod is abstract
767 end
768
769 redef class ANewExpr
770 super AAbsSendExpr
771 end
772
773 redef class ASendExpr
774 super ASuperInitCall
775 # Closure definitions
776 fun closure_defs: nullable Array[AClosureDef] is abstract
777 end
778
779 redef class AReassignFormExpr
780 # Method used through the reassigment operator (require is_typed)
781 fun assign_method: MMMethod is abstract
782 end
783
784 abstract class ASendReassignExpr
785 super ASendExpr
786 super AReassignFormExpr
787 # The invoked method used to read (require is_typed)
788 # prop is the method used to write
789 fun read_prop: MMMethod is abstract
790 end
791
792 redef class ACallReassignExpr
793 super ASendReassignExpr
794 end
795
796 redef class ABraReassignExpr
797 super ASendReassignExpr
798 end
799
800 redef class AAttrFormExpr
801 # Attribute accessed (require is_typed)
802 fun prop: MMAttribute is abstract
803
804 # Attribute type of the acceded attribute (require is_typed)
805 fun attr_type: MMType is abstract
806 end
807
808 redef class ASuperstringExpr
809 fun atype: MMType is abstract
810 end
811
812 redef class AVardeclExpr
813 # Assiociated local variable
814 fun variable: VarVariable is abstract
815 #readable writable var _variable: nullable VarVariable
816 end
817
818 redef class AForExpr
819 # Associated automatic local variable
820 fun variables: Array[AutoVariable] is abstract
821 end
822
823 redef class ASelfExpr
824 # Associated local variable
825 fun variable: ParamVariable is abstract
826 end
827
828 redef class AVarFormExpr
829 # Associated local variable
830 fun variable: Variable is abstract
831 end
832
833 redef class AClosureCallExpr
834 super AAbsAbsSendExpr
835 # Associated closure variable
836 fun variable: ClosureVariable is abstract
837 end
838
839 redef class AClosureDef
840 # Associated closure
841 fun closure: MMClosure is abstract
842
843 # Automatic variables
844 readable writable var _variables: nullable Array[AutoVariable]
845 end
846
847 redef class AMethid
848 # Name of method
849 fun name: nullable Symbol is abstract
850 end
851
852 redef class AExprs
853 # Return an array made of each expr
854 fun to_a: Array[AExpr] do return self.n_exprs.to_a
855 end