nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8394621
)
Add default values for some primitive type attributes.
author
Jean Privat
<jean@pryen.org>
Tue, 27 Jan 2009 18:07:03 +0000
(13:07 -0500)
committer
Jean Privat
<jean@pryen.org>
Tue, 27 Jan 2009 18:07:03 +0000
(13:07 -0500)
20 files changed:
lib/standard/array.nit
patch
|
blob
|
history
lib/standard/stream.nit
patch
|
blob
|
history
src/compiling/compiling_base.nit
patch
|
blob
|
history
src/metamodel/abstractmetamodel.nit
patch
|
blob
|
history
src/metamodel/inheritance.nit
patch
|
blob
|
history
src/metamodel/partial_order.nit
patch
|
blob
|
history
src/mmloader.nit
patch
|
blob
|
history
src/parser/lexer.nit
patch
|
blob
|
history
src/parser/xss/lexer.xss
patch
|
blob
|
history
src/syntax/control_flow.nit
patch
|
blob
|
history
src/syntax/syntax_base.nit
patch
|
blob
|
history
tests/base_virtual_type6.nit
patch
|
blob
|
history
tests/bench_complex_sort.nit
patch
|
blob
|
history
tests/bench_netsim.nit
patch
|
blob
|
history
tests/example_point.nit
patch
|
blob
|
history
tests/example_time.nit
patch
|
blob
|
history
tests/gccbug_attribute_access.nit
patch
|
blob
|
history
tests/test_attr_long.nit
patch
|
blob
|
history
tests/test_combined_assignment.nit
patch
|
blob
|
history
tests/test_create.nit
patch
|
blob
|
history
diff --git
a/lib/standard/array.nit
b/lib/standard/array.nit
index
4e5c678
..
78beeb3
100644
(file)
--- a/
lib/standard/array.nit
+++ b/
lib/standard/array.nit
@@
-325,7
+325,7
@@
special IndexedIterator[E]
_index = 0
end
_index = 0
end
- redef readable attr _index: Int
+ redef readable attr _index: Int = 0
attr _array: AbstractArray[E]
end
attr _array: AbstractArray[E]
end
@@
-510,7
+510,7
@@
special CoupleMap[K, E]
end
# The last positive result given by a index(1) call
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
# Where is the `key' in `_item'?
# return -1 if not found
diff --git
a/lib/standard/stream.nit
b/lib/standard/stream.nit
index
f327d59
..
9046044
100644
(file)
--- a/
lib/standard/stream.nit
+++ b/
lib/standard/stream.nit
@@
-228,7
+228,7
@@
end
class FDIStream
special FDStream
special IStream
class FDIStream
special FDStream
special IStream
- redef readable attr _eof: Bool
+ redef readable attr _eof: Bool = false
redef meth read_char
do
redef meth read_char
do
diff --git
a/src/compiling/compiling_base.nit
b/src/compiling/compiling_base.nit
index
5785775
..
95b1a82
100644
(file)
--- a/
src/compiling/compiling_base.nit
+++ b/
src/compiling/compiling_base.nit
@@
-21,14
+21,14
@@
import syntax
private import utils
redef class ToolContext
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 _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
readable writable attr _ext_prefix: String
end
@@
-64,7
+64,7
@@
class CompilerVisitor
return res
end
# next number for new_number
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.
# 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 _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
# 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_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
# Return the primitive information of the class.
# Return null if the class is not primitive
diff --git
a/src/metamodel/abstractmetamodel.nit
b/src/metamodel/abstractmetamodel.nit
index
debc34f
..
4ce08ef
100644
(file)
--- a/
src/metamodel/abstractmetamodel.nit
+++ b/
src/metamodel/abstractmetamodel.nit
@@
-322,18
+322,18
@@
class MMGlobalClass
end
# Is the global class an interface?
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?
# 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?
# 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
# 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
# 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
# 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
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?
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
protected init(n: Symbol, bc: MMLocalClass)
do
diff --git
a/src/metamodel/inheritance.nit
b/src/metamodel/inheritance.nit
index
50924cd
..
dd6a9ba
100644
(file)
--- a/
src/metamodel/inheritance.nit
+++ b/
src/metamodel/inheritance.nit
@@
-59,7
+59,7
@@
redef class MMLocalClass
# Is the class computing super.
# Used to detect specialization loops.
# 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
# Compute super classes of a class
meth compute_super_classes
diff --git
a/src/metamodel/partial_order.nit
b/src/metamodel/partial_order.nit
index
013ca4b
..
42a0525
100644
(file)
--- a/
src/metamodel/partial_order.nit
+++ b/
src/metamodel/partial_order.nit
@@
-226,7
+226,7
@@
class PartialOrderElement[E]
end
# Cached value of _order.length to validade smallers_cache
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]
# Cached result of smallers
attr _smallers_cache: Set[E]
diff --git
a/src/mmloader.nit
b/src/mmloader.nit
index
4b0b6e5
..
41a64fd
100644
(file)
--- a/
src/mmloader.nit
+++ b/
src/mmloader.nit
@@
-25,10
+25,10
@@
import opts
class ToolContext
special MMContext
# Number of errors
class ToolContext
special MMContext
# Number of errors
- readable attr _error_count: Int
+ readable attr _error_count: Int = 0
# Number of warnings
# Number of warnings
- readable attr _warning_count: Int
+ readable attr _warning_count: Int = 0
# Display an error
meth error(s: String)
# Display an error
meth error(s: String)
diff --git
a/src/parser/lexer.nit
b/src/parser/lexer.nit
index
2ac066c
..
c746092
100644
(file)
--- a/
src/parser/lexer.nit
+++ b/
src/parser/lexer.nit
@@
-1296,7
+1296,7
@@
class Lexer
attr _token: Token
# Lexer current state
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
# 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 _stream_pos: Int
# Current line number in the input stream
- attr _line: Int
+ attr _line: Int = 0
# Current column in the input stream
# Current column in the input stream
- attr _pos: Int
+ attr _pos: Int = 0
# Was the last character a cariage-return?
# Was the last character a cariage-return?
- attr _cr: Bool
+ attr _cr: Bool = false
# If the end of stream?
# If the end of stream?
- attr _eof: Bool
+ attr _eof: Bool = false
# Current working text read from the input stream
attr _text: String
# Current working text read from the input stream
attr _text: String
diff --git
a/src/parser/xss/lexer.xss
b/src/parser/xss/lexer.xss
index
f940e60
..
f3b3247
100644
(file)
--- a/
src/parser/xss/lexer.xss
+++ b/
src/parser/xss/lexer.xss
@@
-25,7
+25,7
@@
class Lexer
attr _token: Token
# Lexer current state
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
# 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 _stream_pos: Int
# Current line number in the input stream
- attr _line: Int
+ attr _line: Int = 0
# Current column in the input stream
# Current column in the input stream
- attr _pos: Int
+ attr _pos: Int = 0
# Was the last character a cariage-return?
# Was the last character a cariage-return?
- attr _cr: Bool
+ attr _cr: Bool = false
# If the end of stream?
# If the end of stream?
- attr _eof: Bool
+ attr _eof: Bool = false
# Current working text read from the input stream
attr _text: String
# Current working text read from the input stream
attr _text: String
diff --git
a/src/syntax/control_flow.nit
b/src/syntax/control_flow.nit
index
86856c8
..
f044cd1
100644
(file)
--- a/
src/syntax/control_flow.nit
+++ b/
src/syntax/control_flow.nit
@@
-52,7
+52,7
@@
special AbsSyntaxVisitor
end
# Number of nested once
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
# 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 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
# 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
# Current controlable block (for or while)
readable writable attr _base_block: AControlableBlock
diff --git
a/src/syntax/syntax_base.nit
b/src/syntax/syntax_base.nit
index
4703700
..
b5ac33b
100644
(file)
--- a/
src/syntax/syntax_base.nit
+++ b/
src/syntax/syntax_base.nit
@@
-457,7
+457,7
@@
end
redef class AType
attr _stype_cache: MMType
redef class AType
attr _stype_cache: MMType
- attr _stype_cached: Bool
+ attr _stype_cached: Bool = false
redef meth get_local_class(v)
do
redef meth get_local_class(v)
do
diff --git
a/tests/base_virtual_type6.nit
b/tests/base_virtual_type6.nit
index
2f092ef
..
94b4c28
100644
(file)
--- a/
tests/base_virtual_type6.nit
+++ b/
tests/base_virtual_type6.nit
@@
-24,10
+24,15
@@
class G[E]
readable writable attr _f: F
readable writable attr _f2: F2
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
end
-var gi = new G[Int]
+var gi = new G[Int](0, 0, 0)
gi.e = 1 + gi.e
gi.e = 1 + gi.f
gi.e = 1 + gi.e
gi.e = 1 + gi.f
diff --git
a/tests/bench_complex_sort.nit
b/tests/bench_complex_sort.nit
index
7ebe0f1
..
b86f796
100644
(file)
--- a/
tests/bench_complex_sort.nit
+++ b/
tests/bench_complex_sort.nit
@@
-89,7
+89,7
@@
special AbstractSorter[Elt]
_is_val1 = not _is_val1
end
_is_val1 = not _is_val1
end
- attr _is_val1: Bool
+ attr _is_val1: Bool = false
init do end
end
init do end
end
diff --git
a/tests/bench_netsim.nit
b/tests/bench_netsim.nit
index
6379f74
..
f11554b
100644
(file)
--- a/
tests/bench_netsim.nit
+++ b/
tests/bench_netsim.nit
@@
-79,7
+79,7
@@
end
class Scheduler
attr _time_list: Array[Couple[Int, WakeUpNode]]
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
meth add_event(n: WakeUpNode, d: Int)
# The node `n' whant to be weaked up in `d' time units
do
diff --git
a/tests/example_point.nit
b/tests/example_point.nit
index
1481487
..
c2363c2
100644
(file)
--- a/
tests/example_point.nit
+++ b/
tests/example_point.nit
@@
-63,6
+63,7
@@
private
init
do
init
do
+ moveto(0, 0)
end
init at(x: Int, y: Int)
end
init at(x: Int, y: Int)
diff --git
a/tests/example_time.nit
b/tests/example_time.nit
index
f8825b0
..
ae694d6
100644
(file)
--- a/
tests/example_time.nit
+++ b/
tests/example_time.nit
@@
-20,7
+20,7
@@
# The Time class represents a quantity of time
class Time
# Internally, the quantity of time is stored in minutes
# 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
# The quantity ot time (in hours)
meth hour: Int
diff --git
a/tests/gccbug_attribute_access.nit
b/tests/gccbug_attribute_access.nit
index
1005b39
..
e04ad13
100644
(file)
--- a/
tests/gccbug_attribute_access.nit
+++ b/
tests/gccbug_attribute_access.nit
@@
-21,7
+21,7
@@
# * try to change the optimization flags
# * try to update your gcc version
class Foo
# * 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
meth run: Int
do
# Under some case gcc produce bad code here and make the if
diff --git
a/tests/test_attr_long.nit
b/tests/test_attr_long.nit
index
40bfe46
..
b29a1aa
100644
(file)
--- a/
tests/test_attr_long.nit
+++ b/
tests/test_attr_long.nit
@@
-15,8
+15,7
@@
# limitations under the License.
class A
# limitations under the License.
class A
-
- attr _a_: Int
+ attr _a_: Int = 0
meth a: Int
do
meth a: Int
do
diff --git
a/tests/test_combined_assignment.nit
b/tests/test_combined_assignment.nit
index
9c2408b
..
7371a8a
100644
(file)
--- a/
tests/test_combined_assignment.nit
+++ b/
tests/test_combined_assignment.nit
@@
-15,8
+15,8
@@
# limitations under the License.
class A
# 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
init do end
meth foo
do
diff --git
a/tests/test_create.nit
b/tests/test_create.nit
index
0ccd49b
..
2eea360
100644
(file)
--- a/
tests/test_create.nit
+++ b/
tests/test_create.nit
@@
-31,7
+31,9
@@
class Toto
end
init
end
init
- do end
+ do
+ _a = 0
+ end
init foo
do
init foo
do