File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ Rust implementation of https://github.com/SeaOfNodes/Simple
66
77This is still a ** work in progress** and the code is not very readable.
88
9- The code is currently equivalent to ` chapter17 ` of the Java implementation at commit ` 8d9cd9a0 ` .
9+ The code is currently equivalent to ` chapter17 ` of the Java implementation at commit ` fd5178db ` .
Original file line number Diff line number Diff line change @@ -357,6 +357,8 @@ impl Node {
357357 } ;
358358 match self . downcast ( & sea. ops ) {
359359 TypedNode :: And ( _) => binary_ints ( "&" ) ,
360+ TypedNode :: Add ( _) => binary_ints ( & sea[ self ] . label ( ) ) ,
361+ TypedNode :: Mul ( _) => binary_ints ( & sea[ self ] . label ( ) ) ,
360362 TypedNode :: Or ( _) => binary_ints ( "|" ) ,
361363 TypedNode :: Xor ( _) => binary_ints ( "^" ) ,
362364 TypedNode :: Sar ( _) => binary_ints ( ">>" ) ,
Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ impl Add {
5959 fn idealize_add ( self , sea : & mut Nodes ) -> Option < Node > {
6060 let lhs = self . inputs ( sea) [ 1 ] ?;
6161 let rhs = self . inputs ( sea) [ 2 ] ?;
62+ if rhs. err ( sea) . is_some ( ) {
63+ return None ;
64+ }
6265 let t2 = rhs. ty ( sea) ?;
6366
6467 // Add of 0. We do not check for (0+x) because this will already
Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ return n.i;
168168 ) ;
169169}
170170
171+ #[ test]
172+ fn test_null_ref_4 ( ) {
173+ test_error_iterate ( "-null-5/null-5;" , "Cannot 'Add' null" ) ;
174+ }
175+
176+ #[ test]
177+ fn test_null_ref_5 ( ) {
178+ test_error_iterate ( "return null+42;" , "Cannot 'Add' null" ) ;
179+ }
180+
171181#[ test]
172182fn test_empty ( ) {
173183 let arena = DroplessArena :: new ( ) ;
Original file line number Diff line number Diff line change @@ -9,15 +9,7 @@ use crate::sea_of_nodes::types::Types;
99fn test_jig ( ) {
1010 let arena = DroplessArena :: new ( ) ;
1111 let types = Types :: new ( & arena) ;
12- let mut parser = Parser :: new (
13- "\
14- int i = 0;
15- i=i=1;
16- return i;
17- //return 3.14;
18- " ,
19- & types,
20- ) ;
12+ let mut parser = Parser :: new ( "return 1;" , & types) ;
2113 let stop = parser. parse ( ) . unwrap ( ) ;
2214 parser. iterate ( stop) ;
2315 parser. type_check ( stop) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments