From: Jean Privat Date: Tue, 13 May 2014 09:30:19 +0000 (-0400) Subject: rest-of-code: prepare for new init X-Git-Tag: v0.6.6~70^2~8 X-Git-Url: http://nitlanguage.org rest-of-code: prepare for new init Give some default values on nullable attributes so they will not be collected. Introduce explicit empty init to avoid the collect of non-nullable attributes. Signed-off-by: Jean Privat --- diff --git a/contrib/pep8analysis/src/ast/rich_instructions.nit b/contrib/pep8analysis/src/ast/rich_instructions.nit index 6989980..8049e34 100644 --- a/contrib/pep8analysis/src/ast/rich_instructions.nit +++ b/contrib/pep8analysis/src/ast/rich_instructions.nit @@ -145,7 +145,8 @@ abstract class ARichBinaryInstruction _n_id = src.n_id parent = src.parent - init(src.location) + init + _location = src.location end end @@ -156,7 +157,8 @@ abstract class ARichUnaryInstruction _n_id = src.n_id parent = src.parent - init(src.location) + init + _location = src.location end end diff --git a/contrib/pep8analysis/src/parser/parser_nodes.nit b/contrib/pep8analysis/src/parser/parser_nodes.nit index 62efb2a..3399de0 100644 --- a/contrib/pep8analysis/src/parser/parser_nodes.nit +++ b/contrib/pep8analysis/src/parser/parser_nodes.nit @@ -6,7 +6,7 @@ import location # Root of the AST hierarchy abstract class ANode - var _location: nullable Location + var _location: nullable Location = null # Location is set during AST building. Once built, location cannon be null # However, manual instanciated nodes may need mode care @@ -96,10 +96,12 @@ end class AInstruction super Prod readable writable var _n_id: TId + init do end end class AOperand super Prod readable var _n_value: AValue + init do end end class AValue super Prod end class ADirective super Prod end @@ -109,10 +111,12 @@ class AListing readable var _n_lines: List[ALine] = new List[ALine] readable var _n_label_decl: nullable ALabelDecl = null readable var _n_end_block: TEndBlock + init do end end class AEmptyLine super ALine readable var _n_eol: TEol + init do end end abstract class ANonEmptyLine super ALine @@ -121,16 +125,19 @@ class AInstructionLine super ANonEmptyLine readable var _n_instruction: AInstruction readable var _n_eol: TEol + init do end end class ADirectiveLine super ANonEmptyLine readable var _n_directive: ADirective readable var _n_eol: TEol + init do end end class ALabelDecl super Prod readable var _n_id: TId readable var _n_colon: TColon + init do end end class AUnaryInstruction super AInstruction @@ -138,6 +145,7 @@ end class ABinaryInstruction super AInstruction readable var _n_operand: AOperand + init do end end class AImmediateOperand super AOperand @@ -146,61 +154,74 @@ class AAnyOperand super AOperand readable var _n_comma: TComma readable var _n_id: TId + init do end end class ALabelValue super AValue readable var _n_id: TId + init do end end class ANumberValue super AValue readable var _n_number: TNumber + init do end end class ACharValue super AValue readable var _n_char: TChar + init do end end class AStringValue super AValue readable var _n_string: TString + init do end end class AHexValue super AValue readable var _n_hex: THex + init do end end class AByteDirective super ADirective readable var _n_tk_byte: TTkByte readable var _n_value: AValue + init do end end class AWordDirective super ADirective readable var _n_tk_word: TTkWord readable var _n_value: AValue + init do end end class ABlockDirective super ADirective readable var _n_tk_block: TTkBlock readable var _n_value: AValue + init do end end class AAsciiDirective super ADirective readable var _n_tk_ascii: TTkAscii readable var _n_value: AValue + init do end end class AAddrssDirective super ADirective readable var _n_tk_addrss: TTkAddrss readable var _n_value: AValue + init do end end class AEquateDirective super ADirective readable var _n_tk_equate: TTkEquate readable var _n_value: AValue + init do end end class ABurnDirective super ADirective readable var _n_tk_burn: TTkBurn readable var _n_value: AValue + init do end end class Start @@ -209,7 +230,7 @@ class Start readable var _n_eof: EOF init(n_base: nullable AListing, n_eof: EOF) do - super(null) + super _n_base = n_base _n_eof = n_eof end diff --git a/examples/shoot/src/shoot_logic.nit b/examples/shoot/src/shoot_logic.nit index 907b8b1..3443a47 100644 --- a/examples/shoot/src/shoot_logic.nit +++ b/examples/shoot/src/shoot_logic.nit @@ -209,7 +209,7 @@ class Missile super Shoot # The target aquired by the missile - var target: nullable Sprite + var target: nullable Sprite = null # When ttl is 0 then the angle stay fixed # The angle is updated toward the target if ttl>0 diff --git a/tests/bench_netsim.nit b/tests/bench_netsim.nit index ca5debe..ae42bee 100644 --- a/tests/bench_netsim.nit +++ b/tests/bench_netsim.nit @@ -32,6 +32,7 @@ class WakeUpNode _scheduler.add_event(self, d) end var _scheduler: Scheduler + init do end end class NodeSource diff --git a/tests/error_spe_attr.nit b/tests/error_spe_attr.nit index 75feb69..e589ec7 100644 --- a/tests/error_spe_attr.nit +++ b/tests/error_spe_attr.nit @@ -15,9 +15,9 @@ # limitations under the License. class A - var _a: Int + var _a: Int = 1 end class B super A - redef var _a: Object + redef var _a: Object = 2 end