Add default values for some primitive type attributes.
authorJean Privat <jean@pryen.org>
Tue, 27 Jan 2009 18:07:03 +0000 (13:07 -0500)
committerJean Privat <jean@pryen.org>
Tue, 27 Jan 2009 18:07:03 +0000 (13:07 -0500)
20 files changed:
lib/standard/array.nit
lib/standard/stream.nit
src/compiling/compiling_base.nit
src/metamodel/abstractmetamodel.nit
src/metamodel/inheritance.nit
src/metamodel/partial_order.nit
src/mmloader.nit
src/parser/lexer.nit
src/parser/xss/lexer.xss
src/syntax/control_flow.nit
src/syntax/syntax_base.nit
tests/base_virtual_type6.nit
tests/bench_complex_sort.nit
tests/bench_netsim.nit
tests/example_point.nit
tests/example_time.nit
tests/gccbug_attribute_access.nit
tests/test_attr_long.nit
tests/test_combined_assignment.nit
tests/test_create.nit

index 4e5c678..78beeb3 100644 (file)
@@ -325,7 +325,7 @@ special IndexedIterator[E]
                _index = 0
        end
 
-       redef readable attr _index: Int
+       redef readable attr _index: Int = 0
        attr _array: AbstractArray[E]
 end
 
@@ -510,7 +510,7 @@ special CoupleMap[K, E]
        end
 
        # The last positive result given by a index(1) call
-       attr _last_index: Int
+       attr _last_index: Int = 0
        
        # Where is the `key' in `_item'?
        # return -1 if not found
index f327d59..9046044 100644 (file)
@@ -228,7 +228,7 @@ end
 class FDIStream
 special FDStream
 special IStream
-       redef readable attr _eof: Bool
+       redef readable attr _eof: Bool = false
        
        redef meth read_char
        do
index 5785775..95b1a82 100644 (file)
@@ -21,14 +21,14 @@ import syntax
 private import utils
 
 redef class ToolContext
-       readable writable attr _global: Bool 
-       readable writable attr _attr_sim: Bool 
+       readable writable attr _global: Bool = false 
+       readable writable attr _attr_sim: Bool = false
        readable writable attr _compdir: String
        readable writable attr _clibdir: String
        readable writable attr _bindir: String
        readable writable attr _output_file: String
-       readable writable attr _boost: Bool
-       readable writable attr _no_cc: Bool
+       readable writable attr _boost: Bool = false
+       readable writable attr _no_cc: Bool = false
        readable writable attr _ext_prefix: String 
 end
 
@@ -64,7 +64,7 @@ class CompilerVisitor
                return res
        end
        # next number for new_number
-       attr _number_cpt: Int
+       attr _number_cpt: Int = 0
 
        # Add an indent level.
        # New decl and instr will be indented.
@@ -94,7 +94,7 @@ class CompilerVisitor
        readable writable attr _ctx: CContext = new CContext
 
        # The current indent lever
-       readable writable attr _indent_level: Int 
+       readable writable attr _indent_level: Int = 0 
 
        # The current ToolContext
        readable writable attr _tc: ToolContext 
@@ -164,7 +164,7 @@ redef class MMLocalClass
        attr _primitive_info_cache: PrimitiveInfo
 
        # If primitive_info result cached?
-       attr _primitive_info_b: Bool
+       attr _primitive_info_b: Bool = false
 
        # Return the primitive information of the class.
        # Return null if the class is not primitive
index debc34f..4ce08ef 100644 (file)
@@ -322,18 +322,18 @@ class MMGlobalClass
        end
 
        # Is the global class an interface?
-       readable writable attr _is_interface: Bool
+       readable writable attr _is_interface: Bool = false
 
        # Is the global class an abstract class?
-       readable writable attr _is_abstract: Bool
+       readable writable attr _is_abstract: Bool = false
 
        # Is the global class a universal class?
-       readable writable attr _is_universal: Bool
+       readable writable attr _is_universal: Bool = false
 
        # Visibility of the global class
        # 1 -> public
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
 
        # Is the global class a mixin class?
        # A mixin class inherits all constructors from a superclass
@@ -605,7 +605,7 @@ class MMGlobalProperty
        # 1 -> public
        # 2 -> protected
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
 end
 
 # Local properties are properties defined (explicitely or not) in a local class
@@ -656,7 +656,7 @@ class MMLocalProperty
        redef meth to_s do return name.to_s
 
        # Is the concrete property contain a `super' in the body?
-       readable writable attr _need_super: Bool
+       readable writable attr _need_super: Bool = false
 
        protected init(n: Symbol, bc: MMLocalClass)
        do
index 50924cd..dd6a9ba 100644 (file)
@@ -59,7 +59,7 @@ redef class MMLocalClass
 
        # Is the class computing super.
        # Used to detect specialization loops.
-       attr _computing_super: Bool 
+       attr _computing_super: Bool = false 
 
        # Compute super classes of a class
        meth compute_super_classes
index 013ca4b..42a0525 100644 (file)
@@ -226,7 +226,7 @@ class PartialOrderElement[E]
        end
        
        # Cached value of _order.length to validade smallers_cache
-       attr _smallers_last_length: Int
+       attr _smallers_last_length: Int = 0
 
        # Cached result of smallers
        attr _smallers_cache: Set[E]
index 4b0b6e5..41a64fd 100644 (file)
@@ -25,10 +25,10 @@ import opts
 class ToolContext
 special MMContext
        # Number of errors
-       readable attr _error_count: Int 
+       readable attr _error_count: Int = 0 
 
        # Number of warnings
-       readable attr _warning_count: Int 
+       readable attr _warning_count: Int = 0
 
        # Display an error
        meth error(s: String)
index 2ac066c..c746092 100644 (file)
@@ -1296,7 +1296,7 @@ class Lexer
        attr _token: Token
 
        # Lexer current state
-       attr _state: Int
+       attr _state: Int = 0
 
        # Name of the stream (as given to tokens)
        readable attr _filename: String 
@@ -1311,16 +1311,16 @@ class Lexer
        attr _stream_pos: Int
 
        # Current line number in the input stream
-       attr _line: Int
+       attr _line: Int = 0
 
        # Current column in the input stream
-       attr _pos: Int
+       attr _pos: Int = 0
 
        # Was the last character a cariage-return?
-       attr _cr: Bool
+       attr _cr: Bool = false
 
        # If the end of stream?
-       attr _eof: Bool
+       attr _eof: Bool = false
 
        # Current working text read from the input stream
        attr _text: String
index f940e60..f3b3247 100644 (file)
@@ -25,7 +25,7 @@ class Lexer
        attr _token: Token
 
        # Lexer current state
-       attr _state: Int
+       attr _state: Int = 0
 
        # Name of the stream (as given to tokens)
        readable attr _filename: String 
@@ -40,16 +40,16 @@ class Lexer
        attr _stream_pos: Int
 
        # Current line number in the input stream
-       attr _line: Int
+       attr _line: Int = 0
 
        # Current column in the input stream
-       attr _pos: Int
+       attr _pos: Int = 0
 
        # Was the last character a cariage-return?
-       attr _cr: Bool
+       attr _cr: Bool = false
 
        # If the end of stream?
-       attr _eof: Bool
+       attr _eof: Bool = false
 
        # Current working text read from the input stream
        attr _text: String
index 86856c8..f044cd1 100644 (file)
@@ -52,7 +52,7 @@ special AbsSyntaxVisitor
        end
 
        # Number of nested once
-       readable writable attr _once_count: Int
+       readable writable attr _once_count: Int = 0
 
        # Current knowledge about variables types
        readable writable attr _control_flow_ctx: ControlFlowContext
@@ -82,11 +82,11 @@ private class ControlFlowContext
        readable attr _prev: ControlFlowContext
 
        # Is a control flow break met? (return, break, continue)
-       readable writable attr _unreash: Bool
+       readable writable attr _unreash: Bool = false
 
        # Is a control flow already broken?
        # Used to avoid repeating the same error message
-       readable writable attr _already_unreash: Bool
+       readable writable attr _already_unreash: Bool = false
 
        # Current controlable block (for or while)
        readable writable attr _base_block: AControlableBlock
index 4703700..b5ac33b 100644 (file)
@@ -457,7 +457,7 @@ end
 
 redef class AType
        attr _stype_cache: MMType
-       attr _stype_cached: Bool
+       attr _stype_cached: Bool = false
 
        redef meth get_local_class(v)
        do
index 2f092ef..94b4c28 100644 (file)
@@ -24,10 +24,15 @@ class G[E]
        readable writable attr _f: F
        readable writable attr _f2: F2
 
-       init do end
+       init(e: E, f: F, f2: F2)
+       do
+               _e = e
+               _f = f
+               _f2 = f2
+       end
 end
 
-var gi = new G[Int]
+var gi = new G[Int](0, 0, 0)
 
 gi.e = 1 + gi.e
 gi.e = 1 + gi.f
index 7ebe0f1..b86f796 100644 (file)
@@ -89,7 +89,7 @@ special AbstractSorter[Elt]
                _is_val1 = not _is_val1
        end
        
-       attr _is_val1: Bool
+       attr _is_val1: Bool = false
 
        init do end
 end
index 6379f74..f11554b 100644 (file)
@@ -79,7 +79,7 @@ end
 
 class Scheduler
        attr _time_list: Array[Couple[Int, WakeUpNode]]
-       attr _time: Int # What time is it ?
+       attr _time: Int = 0 # What time is it ?
        meth add_event(n: WakeUpNode, d: Int)
        # The node `n' whant to be weaked up in `d' time units
        do
index 1481487..c2363c2 100644 (file)
@@ -63,6 +63,7 @@ private
 
        init
        do
+               moveto(0, 0)
        end
 
        init at(x: Int, y: Int)
index f8825b0..ae694d6 100644 (file)
@@ -20,7 +20,7 @@
 # The Time class represents a quantity of time
 class Time
        # Internally, the quantity of time is stored in minutes
-       readable writable attr _min: Int
+       readable writable attr _min: Int = 0
 
        # The quantity ot time (in hours)
        meth hour: Int
index 1005b39..e04ad13 100644 (file)
@@ -21,7 +21,7 @@
 # * try to change the optimization flags
 # * try to update your gcc version
 class Foo
-       attr _count: Int
+       attr _count: Int = 0
        meth run: Int
        do
                # Under some case gcc produce bad code here and make the if
index 40bfe46..b29a1aa 100644 (file)
@@ -15,8 +15,7 @@
 # limitations under the License.
 
 class A
-
-       attr _a_: Int
+       attr _a_: Int = 0
 
        meth a: Int
        do
index 9c2408b..7371a8a 100644 (file)
@@ -15,8 +15,8 @@
 # limitations under the License.
 
 class A
-       readable writable attr _a: Int #!alt1#
-       #alt1#readable writable attr _a: Object
+       readable writable attr _a: Int = 0#!alt1#
+       #alt1#readable writable attr _a: Object = 0
        init do end
        meth foo
        do
index 0ccd49b..2eea360 100644 (file)
@@ -31,7 +31,9 @@ class Toto
        end
 
        init
-       do end
+       do 
+               _a = 0
+       end
 
        init foo
        do