clean: make some classes abstract or interfaces
authorJean Privat <jean@pryen.org>
Sun, 18 Mar 2012 01:42:04 +0000 (21:42 -0400)
committerJean Privat <jean@pryen.org>
Tue, 10 Apr 2012 18:30:30 +0000 (14:30 -0400)
Some even have 'abstract' in their names.

Signed-off-by: Jean Privat <jean@pryen.org>

28 files changed:
lib/filter_stream.nit
lib/opts.nit
lib/standard/collection/array.nit
lib/standard/collection/hash_collection.nit
lib/standard/collection/sorter.nit
lib/standard/exec.nit
lib/standard/file.nit
lib/standard/stream.nit
lib/standard/string.nit
src/abstracttool.nit
src/compiling/table_computation.nit
src/global/instantiated_type_analysis.nit
src/global/reachable_as_init.nit
src/global/reachable_from_init_method_analysis.nit
src/global/reachable_method_analysis.nit
src/icode/icode_tools.nit
src/metamodel/abstractmetamodel.nit
src/metamodel/static_type.nit
src/metamodel/type_formal.nit
src/metamodel/virtualtype.nit
src/mmloader.nit
src/nitdoc.nit
src/parser/parser_nodes.nit
src/parser/parser_prod.nit
src/parser/xss/nodes.xss
src/syntax/scope.nit
src/syntax/syntax_base.nit
src/syntax/typing.nit

index 66366c6..5286c7c 100644 (file)
@@ -14,7 +14,7 @@
 class FilterIStream
        super IStream
        # Filter readed elements
-       readable var _stream: nullable IStream
+       readable var _stream: nullable IStream = null
 
        redef fun eof: Bool
        do
@@ -31,7 +31,7 @@ end
 class FilterOStream
        super OStream
        # Filter outputed elements
-       readable var _stream: nullable OStream
+       readable var _stream: nullable OStream = null
 
        # Can the stream be used to write
        redef fun is_writable: Bool
index 1d085b8..9d6eac1 100644 (file)
@@ -15,7 +15,7 @@
 module opts
 
 # Super class of all option's class
-class Option
+abstract class Option
        # Names for the option (including long and short ones)
        readable var _names: Array[String]
 
@@ -109,7 +109,7 @@ class OptionCount
 end
 
 # Option with one mandatory parameter
-class OptionParameter
+abstract class OptionParameter
        super Option
        protected fun convert(str: String): VALUE is abstract
 
index c5e2c7f..fa69711 100644 (file)
@@ -18,7 +18,7 @@ package array
 import abstract_collection
 
 # One dimension array of objects.
-class AbstractArrayRead[E]
+abstract class AbstractArrayRead[E]
        super SequenceRead[E]
 
        redef readable var _length: Int = 0
@@ -154,7 +154,7 @@ class AbstractArrayRead[E]
 end
 
 # Resizable one dimension array of objects.
-class AbstractArray[E]
+abstract class AbstractArray[E]
        super AbstractArrayRead[E]
        super Sequence[E]
 
index 989308c..0c772b8 100644 (file)
@@ -17,7 +17,7 @@ import array
 import hash
 
 # A HashCollection is an array of HashNode[K] indexed by the K hash value
-private class HashCollection[K: Object, N: HashNode[K]]
+private abstract class HashCollection[K: Object, N: HashNode[Object]]
        super ArrayCapable[nullable N]
 
        var _array: nullable NativeArray[nullable N] = null # Used to store items
@@ -186,7 +186,7 @@ private class HashCollection[K: Object, N: HashNode[K]]
        end
 end
 
-private class HashNode[K: Object]
+private abstract class HashNode[K: Object]
        var _key: K
        type N: HashNode[K]
        readable writable var _next_item: nullable N = null
index 99c58a1..7010907 100644 (file)
@@ -18,7 +18,7 @@ package sorter
 import array
 
 # This abstract class generalizes ways to sort an array
-class AbstractSorter[E: Object]
+interface AbstractSorter[E: Object]
        # Compare `a' and `b'.
        # Returns:
        #       -1 if a < b
index 45696c0..a9f59da 100644 (file)
@@ -19,7 +19,6 @@ import stream
 
 # Simple sub-processus
 class Process
-
        # The pid of the processus
        fun id: Int do return _data.id
 
index 4871113..2bd2ae4 100644 (file)
@@ -49,7 +49,7 @@ redef class Object
 end
 
 # File Abstract Stream
-class FStream
+abstract class FStream
        super IOS
        # The path of the file.
        readable var _path: nullable String = null
index 1a90d56..88a73ac 100644 (file)
@@ -16,13 +16,13 @@ package stream
 import string
 
 # Abstract stream class
-class IOS
+interface IOS
        # close the stream
        fun close is abstract
 end
 
 # Abstract input streams
-class IStream
+interface IStream
        super IOS
        # Read a character. Return its ASCII value, -1 on EOF or timeout
        fun read_char: Int is abstract
@@ -81,7 +81,7 @@ class IStream
 end
 
 # Abstract output stream
-class OStream
+interface OStream
        super IOS
        # write a string
        fun write(s: String) is abstract
@@ -91,7 +91,7 @@ class OStream
 end
 
 # Input streams with a buffer
-class BufferedIStream
+abstract class BufferedIStream
        super IStream
        redef fun read_char
        do
@@ -203,14 +203,14 @@ class BufferedIStream
        end
 end
 
-class IOStream
+interface IOStream
        super IStream
        super OStream
 end
 
 ##############################################################"
 
-class FDStream
+abstract class FDStream
        super IOS
        # File description
        var _fd: Int
index 6089102..08921f7 100644 (file)
@@ -605,7 +605,7 @@ class NativeString
 end
 
 # StringCapable objects can create native strings
-class StringCapable
+interface StringCapable
        protected fun calloc_string(size: Int): NativeString is intern
 end
 
index bed57f4..dc3187e 100644 (file)
@@ -23,7 +23,7 @@ import mmloader
 import syntax
 private import nit_version
 
-class AbstractCompiler
+abstract class AbstractCompiler
        super ToolContext
 
        init(tool_name: String)
index 08d1733..6138e85 100644 (file)
@@ -23,7 +23,7 @@ private import primitive_info
 import program
 
 # Something that store color of table elements
-class ColorContext
+abstract class ColorContext
        var _colors: HashMap[TableElt, Int] = new HashMap[TableElt, Int]
 
        # The color of a table element.
@@ -411,12 +411,12 @@ end
 ###############################################################################
 
 # An element of a class, an instance or a module table
-abstract class AbsTableElt
+interface AbsTableElt
 end
 
 # An element of a class or an instance table
 # Such an elements represent method function pointers, attribute values, etc.
-abstract class TableElt
+interface TableElt
        super AbsTableElt
        # Is the element conflict to class `c' (used for coloring)
        fun is_related_to(c: MMLocalClass): Bool is abstract
@@ -430,7 +430,7 @@ end
 
 # An element of a module table
 # Such an elements represent colors or identifiers
-abstract class ModuleTableElt
+interface ModuleTableElt
        super AbsTableElt
 end
 
@@ -477,7 +477,7 @@ class TableEltAttr
 end
 
 # An element representing a class information
-class AbsTableEltClass
+abstract class AbsTableEltClass
        super AbsTableElt
        # The local class where the information comes from
        readable var _local_class: MMLocalClass
@@ -489,7 +489,7 @@ class AbsTableEltClass
 end
 
 # An element of a class table representing a class information
-class TableEltClass
+abstract class TableEltClass
        super TableElt
        super AbsTableEltClass
        redef fun is_related_to(c)
index f052eda..d90bcce 100644 (file)
@@ -57,7 +57,7 @@ end
 # Subclasses of this class would represent an analysis that produces
 # at least a way of knowing if a class is instantiated somewhere in a
 # method that is reachable from the entry point of the program
-class InstantiatedTypeAnalysis
+interface InstantiatedTypeAnalysis
        fun is_class_instantiated(local_class: MMLocalClass): Bool is abstract
 end
 
index 2f65f7a..d6c0f4e 100644 (file)
@@ -45,7 +45,7 @@ end
 # at least a way of knowing if an initializer is called at least once
 # as an initializer (and not as part of another initializer)
 # in a specific class
-class ReachableAsInitAnalysis
+interface ReachableAsInitAnalysis
        fun is_method_reachable_as_init(method: MMMethod, c: MMLocalClass): Bool is abstract
 end
 
index fcffe1e..4735012 100644 (file)
@@ -53,7 +53,7 @@ end
 # Subclasses of this class would represent an analysis that produces
 # at least a way of knowing if a property is reachable from at least
 # one init in the program
-class ReachableFromInitMethodAnalysis
+interface ReachableFromInitMethodAnalysis
        fun is_iroutine_reachable_from_init(ir: nullable IRoutine): Bool is abstract
        fun is_method_reachable_from_init(method: MMMethod): Bool is abstract
 end
index a7ac075..bef70ff 100644 (file)
@@ -50,7 +50,7 @@ end
 # Subclasses of this class would represent an analysis that produces
 # at least a way of knowing if a property is reachable from the entry
 # point of the program
-class ReachableMethodAnalysis
+interface ReachableMethodAnalysis
        fun is_iroutine_reachable(ir: nullable IRoutine): Bool is abstract
        fun is_method_reachable(method: MMMethod): Bool is abstract
 end
index ff2b2e8..3c5c90c 100644 (file)
@@ -19,7 +19,7 @@ module icode_tools
 import icode_builder
 
 # A simple visitor to visit icode structures
-class ICodeVisitor
+abstract class ICodeVisitor
        # Called when a iregister is read in a icode
        fun visit_iregister_read(ic: ICode, r: IRegister) do end
 
index 111c73d..9b0fc57 100644 (file)
@@ -22,7 +22,7 @@ import partial_order
 import location
 
 # The main singleton which knows everything
-class MMContext
+abstract class MMContext
 
        init do end
 
@@ -107,7 +107,7 @@ class MMDirectory
 end
 
 # A module is a Nit file
-class MMModule
+abstract class MMModule
        # Global context
        readable var _context: MMContext 
 
@@ -330,7 +330,7 @@ class MMGlobalClass
 end
 
 # Local classes are classes defined, refined or imported in a module
-class MMLocalClass
+abstract class MMLocalClass
        # The name of the local class
        readable var _name: Symbol
 
@@ -594,7 +594,7 @@ class MMGlobalProperty
 end
 
 # Local properties are properties defined (explicitely or not) in a local class
-class MMLocalProperty
+abstract class MMLocalProperty
        # The name of the property
        readable var _name: Symbol
 
@@ -656,7 +656,7 @@ class MMLocalProperty
 end
 
 # Attribute local properties
-class MMAttribute
+abstract class MMAttribute
        super MMLocalProperty
 end
 
@@ -666,7 +666,7 @@ class MMExplicitImport
 end
 
 # Method local properties
-class MMMethod
+abstract class MMMethod
        super MMLocalProperty
        # Is the method defined with intern
        fun is_intern: Bool is abstract
@@ -685,7 +685,7 @@ class MMMethod
 end
 
 # Concrete local classes
-class MMConcreteClass
+abstract class MMConcreteClass
        super MMLocalClass
 end
 
index 7e45da4..09db136 100644 (file)
@@ -464,7 +464,7 @@ class MMNullableType
        end
 end
 
-class MMTypeClass 
+abstract class MMTypeClass
        super MMType
        redef readable var _local_class: MMLocalClass
        redef fun mmmodule do return _local_class.mmmodule end
index 8ab8b8b..afe5a21 100644 (file)
@@ -26,7 +26,7 @@ redef class MMType
 end
 
 # Formal types are named indirect types
-class MMTypeFormal
+abstract class MMTypeFormal
        super MMType
        redef fun is_valid do return _bound != null and _bound.is_valid
 
index 527f20e..323c37b 100644 (file)
@@ -26,7 +26,7 @@ redef class MMGlobalProperty
 end
 
 # Virtual type properties
-class MMTypeProperty
+abstract class MMTypeProperty
        super MMLocalProperty
        # The virtual static type associated
        fun stype_for(recv: MMType): nullable MMVirtualType
index 0230cc5..189a46b 100644 (file)
@@ -186,7 +186,7 @@ redef class ToolContext
 end
 
 # A load handler know how to load a specific module type
-class ModuleLoader
+interface ModuleLoader
        # Type of module loaded by the loader
        type MODULE: MMModule
 
index 2765264..5697a65 100644 (file)
@@ -427,7 +427,7 @@ class AlphaSorter[E: Object]
 end
 
 # Generalization of metamodel entities
-class MMEntity
+interface MMEntity
        # Return a link to
        fun html_link(dctx: DocContext): String is abstract
 
index fdc13b3..574e512 100644 (file)
@@ -56,7 +56,7 @@ end
 class TComment
        super Token
 end
-class TokenKeyword
+abstract class TokenKeyword
        super Token
        redef fun to_s
        do
@@ -234,7 +234,7 @@ end
 class TAssign
        super Token
 end
-class TokenOperator
+abstract class TokenOperator
        super Token
        redef fun to_s
        do
@@ -322,7 +322,7 @@ class TAttrid
                do return "attribute '{text}'"
        end
 end
-class TokenLiteral
+abstract class TokenLiteral
        super Token
        redef fun to_s
        do
@@ -389,7 +389,7 @@ class AModuledecl
     readable var _n_kwmodule: TKwmodule
     readable var _n_name: AModuleName
 end
-class AImport super Prod end
+abstract class AImport super Prod end
 class AStdImport
        super AImport
     readable var _n_visibility: AVisibility
@@ -402,7 +402,7 @@ class ANoImport
     readable var _n_kwimport: TKwimport
     readable var _n_kwend: TKwend
 end
-class AVisibility super Prod end
+abstract class AVisibility super Prod end
 class APublicVisibility
        super AVisibility
 end
@@ -418,7 +418,7 @@ class AIntrudeVisibility
        super AVisibility
     readable var _n_kwintrude: TKwintrude
 end
-class AClassdef super Prod
+abstract class AClassdef super Prod
     readable var _n_propdefs: List[APropdef] = new List[APropdef]
 end
 class AStdClassdef
@@ -439,7 +439,7 @@ end
 class AMainClassdef
        super AClassdef
 end
-class AClasskind super Prod end
+abstract class AClasskind super Prod end
 class AConcreteClasskind
        super AClasskind
     readable var _n_kwclass: TKwclass
@@ -472,7 +472,7 @@ class ASuperclass
     readable var _n_kwsuper: nullable TKwsuper = null
     readable var _n_type: AType
 end
-class APropdef super Prod
+abstract class APropdef super Prod
     readable var _n_doc: nullable ADoc = null
 end
 class AAttrPropdef
@@ -491,7 +491,7 @@ class AAttrPropdef
            if n_id != null then return n_id.location else return n_id2.location
     end
 end
-class AMethPropdef
+abstract class AMethPropdef
        super APropdef
     readable var _n_kwredef: nullable TKwredef = null
     readable var _n_visibility: nullable AVisibility
@@ -514,7 +514,7 @@ class AInternMethPropdef
        super AMethPropdef
     readable var _n_kwmeth: TKwmeth
 end
-class AExternPropdef
+abstract class AExternPropdef
        super AMethPropdef
     readable var _n_extern: nullable TString = null
     readable var _n_extern_calls: nullable AExternCalls = null
@@ -529,7 +529,8 @@ class AConcreteMethPropdef
     readable var _n_kwmeth: nullable TKwmeth
     readable var _n_block: nullable AExpr = null
 end
-class AInitPropdef
+abstract class AInitPropdef
+       super AMethPropdef
 end
 class AConcreteInitPropdef
        super AConcreteMethPropdef
@@ -552,10 +553,10 @@ class AExternCalls
     readable var _n_kwimport: TKwimport
     readable var _n_extern_calls: List[AExternCall] = new List[AExternCall]
 end
-class AExternCall
+abstract class AExternCall
        super Prod
 end
-class APropExternCall
+abstract class APropExternCall
 special AExternCall
 end
 class ALocalPropExternCall
@@ -576,7 +577,7 @@ class ASuperExternCall
 special AExternCall
     readable var _n_kwsuper: TKwsuper
 end
-class ACastExternCall
+abstract class ACastExternCall
 special AExternCall
 end
 class ACastAsExternCall
@@ -606,7 +607,7 @@ class ATypePropdef
     readable var _n_id: TClassid
     readable var _n_type: AType
 end
-class AAble super Prod
+abstract class AAble super Prod
     readable var _n_visibility: nullable AVisibility = null
     readable var _n_kwredef: nullable TKwredef = null
 end
@@ -618,7 +619,7 @@ class AWriteAble
        super AAble
     readable var _n_kwwritable: TKwwritable
 end
-class AMethid super Prod end
+abstract class AMethid super Prod end
 class AIdMethid
        super AMethid
     readable var _n_id: TId
@@ -728,7 +729,7 @@ class ALabel
     readable var _n_kwlabel: TKwlabel
     readable var _n_id: TId
 end
-class AExpr super Prod end
+abstract class AExpr super Prod end
 class ABlockExpr
        super AExpr
     readable var _n_expr: List[AExpr] = new List[AExpr]
@@ -747,7 +748,7 @@ class AReturnExpr
     readable var _n_kwreturn: nullable TKwreturn = null
     readable var _n_expr: nullable AExpr = null
 end
-class ALabelable
+abstract class ALabelable
        super Prod
     readable var _n_label: nullable ALabel = null
 end
@@ -819,12 +820,12 @@ class AAssertExpr
     readable var _n_expr: AExpr
     readable var _n_else: nullable AExpr = null
 end
-class AAssignFormExpr
+abstract class AAssignFormExpr
        super AExpr
     readable var _n_assign: TAssign
     readable var _n_value: AExpr
 end
-class AReassignFormExpr
+abstract class AReassignFormExpr
        super AExpr
     readable var _n_assign_op: AAssignOp
     readable var _n_value: AExpr
@@ -833,16 +834,16 @@ class AOnceExpr
        super AProxyExpr
     readable var _n_kwonce: TKwonce
 end
-class ASendExpr
+abstract class ASendExpr
        super AExpr
     readable var _n_expr: AExpr
     readable var _n_closure_defs: List[AClosureDef] = new List[AClosureDef]
 end
-class ABinopExpr
+abstract class ABinopExpr
        super ASendExpr
     readable var _n_expr2: AExpr
 end
-class ABoolExpr
+abstract class ABoolExpr
        super AExpr
 end
 class AOrExpr
@@ -928,7 +929,7 @@ class ANewExpr
     readable var _n_id: nullable TId = null
     readable var _n_args: AExprs
 end
-class AAttrFormExpr
+abstract class AAttrFormExpr
        super AExpr
     readable var _n_expr: AExpr
     readable var _n_id: TAttrid
@@ -940,12 +941,12 @@ class AAttrAssignExpr
        super AAttrFormExpr
        super AAssignFormExpr
 end
-class ACallFormExpr
+abstract class ACallFormExpr
        super ASendExpr
     readable var _n_id: TId
     readable var _n_args: AExprs
 end
-class ASendReassignFormExpr
+abstract class ASendReassignFormExpr
        super ASendExpr
        super AReassignFormExpr
 end
@@ -977,7 +978,7 @@ class AInitExpr
     readable var _n_kwinit: TKwinit
     readable var _n_args: AExprs
 end
-class ABraFormExpr
+abstract class ABraFormExpr
        super ASendExpr
     readable var _n_args: AExprs
 end
@@ -988,7 +989,7 @@ class ABraAssignExpr
        super ABraFormExpr
        super AAssignFormExpr
 end
-class AVarFormExpr
+abstract class AVarFormExpr
        super AExpr
     readable var _n_id: TId
 end
@@ -1013,7 +1014,7 @@ class AVarReassignExpr
        super AVarFormExpr
        super AReassignFormExpr
 end
-class ARangeExpr
+abstract class ARangeExpr
        super AExpr
     readable var _n_expr: AExpr
     readable var _n_expr2: AExpr
@@ -1063,7 +1064,7 @@ class ACharExpr
        super AExpr
     readable var _n_char: TChar
 end
-class AStringFormExpr
+abstract class AStringFormExpr
        super AExpr
 end
 class AStringExpr
@@ -1091,7 +1092,7 @@ class AParExpr
     readable var _n_opar: TOpar
     readable var _n_cpar: TCpar
 end
-class AProxyExpr
+abstract class AProxyExpr
        super AExpr
     readable var _n_expr: AExpr
 end
@@ -1116,7 +1117,7 @@ class AIssetAttrExpr
        super AAttrFormExpr
     readable var _n_kwisset: TKwisset
 end
-class AExprs
+abstract class AExprs
        super Prod 
     readable var _n_exprs: List[AExpr] = new List[AExpr]
 end
@@ -1133,7 +1134,7 @@ class ABraExprs
     readable var _n_obra: TObra
     readable var _n_cbra: TCbra
 end
-class AAssignOp super Prod end
+abstract class AAssignOp super Prod end
 class APlusAssignOp
        super AAssignOp
     readable var _n_pluseq: TPluseq
@@ -1151,7 +1152,7 @@ class AClosureDef
     readable var _n_expr: nullable AExpr = null
     redef fun hot_location do return n_id.location
 end
-class AClosureId
+abstract class AClosureId
        super Prod
 end
 class ASimpleClosureId
index 7df0343..6899b21 100644 (file)
@@ -47,7 +47,7 @@ redef class Prod
 end
 
 # Abstract standard visitor
-class Visitor
+abstract class Visitor
        # What the visitor do when a node is visited
         # Concrete visitors should redefine this method.
         protected fun visit(e: nullable ANode) is abstract
index e5eb9da..a07d4ef 100644 (file)
@@ -79,7 +79,7 @@ redef class Prod
 end
 
 # Abstract standard visitor
-class Visitor
+abstract class Visitor
        # What the visitor do when a node is visited
         # Concrete visitors should redefine this method.
         protected fun visit(e: nullable PNode) is abstract
index dbe9f73..dedd967 100644 (file)
@@ -229,7 +229,7 @@ end
 
 ###############################################################################
 
-class AEscapeExpr
+abstract class AEscapeExpr
        super ALabelable
        # The associated escapable block
        readable var _escapable: nullable EscapableBlock
index b4fb77c..a8d166d 100644 (file)
@@ -144,7 +144,7 @@ class MMSrcAttribute
 end
 
 # Concrete NIT source method
-class MMSrcMethod
+abstract class MMSrcMethod
        super MMMethod
        redef fun is_intern do return false
        redef fun is_extern do return false
@@ -153,7 +153,7 @@ class MMSrcMethod
 end
 
 # Concrete NIT source method for an automatic accesor
-class MMAttrImplementationMethod
+abstract class MMAttrImplementationMethod
        super MMSrcMethod
        redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
@@ -295,7 +295,7 @@ end
 ###############################################################################
 
 # Visitor used during the syntax analysis
-class AbsSyntaxVisitor
+abstract class AbsSyntaxVisitor
        super Visitor
        fun get_type_by_name(clsname: Symbol): MMType
        do
@@ -739,7 +739,7 @@ redef class AExpr
        fun stype: MMType is abstract
 end
 
-class AAbsAbsSendExpr
+abstract class AAbsAbsSendExpr
        super AExpr
        # The signature of the called property (require is_typed)
        fun prop_signature: MMSignature is abstract
@@ -748,7 +748,7 @@ class AAbsAbsSendExpr
        fun raw_arguments: Array[AExpr] is abstract
 end
 
-class AAbsSendExpr
+abstract class AAbsSendExpr
        super AAbsAbsSendExpr
        # The invoked method (require is_typed)
        fun prop: MMMethod is abstract
@@ -757,7 +757,7 @@ class AAbsSendExpr
        fun return_type: nullable MMType is abstract
 end
 
-class ASuperInitCall
+abstract class ASuperInitCall
        super AAbsSendExpr
 end
 
@@ -781,7 +781,7 @@ redef class AReassignFormExpr
        fun assign_method: MMMethod is abstract
 end
 
-class ASendReassignExpr
+abstract class ASendReassignExpr
        super ASendExpr
        super AReassignFormExpr
        # The invoked method used to read (require is_typed)
index e75e2e4..ffcdec1 100644 (file)
@@ -555,7 +555,7 @@ redef class AAbortExpr
 end
 
 # An abstract control structure with feature escapable block
-class AAbsControl
+abstract class AAbsControl
        super AExpr
        # The corresponding escapable block
        readable var _escapable: nullable EscapableBlock
@@ -2038,7 +2038,7 @@ redef class AClosureDef
        end
 end
 
-class ATypeCheckExpr
+abstract class ATypeCheckExpr
        super AExpr
        private fun check_expr_cast(v: TypingVisitor, n_expr: AExpr, n_type: AType)
        do