cgen: fix ->
							parent
							
								
									a58be3af0c
								
							
						
					
					
						commit
						754a6cc93e
					
				|  | @ -319,9 +319,9 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { | ||||||
| 	if it.is_method { | 	if it.is_method { | ||||||
| 		mut styp := g.typ(it.receiver.typ) | 		mut styp := g.typ(it.receiver.typ) | ||||||
| 		// if table.type_nr_muls(it.receiver.typ) > 0 {
 | 		// if table.type_nr_muls(it.receiver.typ) > 0 {
 | ||||||
| 		if it.rec_mut { | 		// if it.rec_mut {
 | ||||||
| 			styp += '*' | 		// styp += '*'
 | ||||||
| 		} | 		// }
 | ||||||
| 		g.write('$styp $it.receiver.name') | 		g.write('$styp $it.receiver.name') | ||||||
| 		// TODO mut
 | 		// TODO mut
 | ||||||
| 		g.definitions.write('$styp $it.receiver.name') | 		g.definitions.write('$styp $it.receiver.name') | ||||||
|  | @ -642,7 +642,8 @@ fn (g mut Gen) expr(node ast.Expr) { | ||||||
| 		} | 		} | ||||||
| 		ast.SelectorExpr { | 		ast.SelectorExpr { | ||||||
| 			g.expr(it.expr) | 			g.expr(it.expr) | ||||||
| 			if table.type_nr_muls(it.expr_type) > 0 { | 			// if table.type_nr_muls(it.expr_type) > 0 {
 | ||||||
|  | 			if table.type_is_ptr(it.expr_type) { | ||||||
| 				g.write('->') | 				g.write('->') | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ i < 10; i++) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void User_inc_age(User* u, int n) { | void User_inc_age(User* u, int n) { | ||||||
| 	u.age += n; | 	u->age += n; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int get_int(string a) { | int get_int(string a) { | ||||||
|  |  | ||||||
|  | @ -80,7 +80,7 @@ fn (p mut Parser) fn_decl() ast.FnDecl { | ||||||
| 		p.next() | 		p.next() | ||||||
| 		rec_name = p.check_name() | 		rec_name = p.check_name() | ||||||
| 		if p.tok.kind == .key_mut { | 		if p.tok.kind == .key_mut { | ||||||
| 			p.next() | 			// p.next()
 | ||||||
| 			rec_mut = true | 			rec_mut = true | ||||||
| 		} | 		} | ||||||
| 		rec_type = p.parse_type() | 		rec_type = p.parse_type() | ||||||
|  |  | ||||||
|  | @ -90,6 +90,10 @@ pub fn (p mut Parser) parse_type() table.Type { | ||||||
| 		p.check(.amp) | 		p.check(.amp) | ||||||
| 		nr_muls++ | 		nr_muls++ | ||||||
| 	} | 	} | ||||||
|  | 	if p.tok.kind == .key_mut { | ||||||
|  | 		nr_muls++ | ||||||
|  | 		p.next() | ||||||
|  | 	} | ||||||
| 	is_c := p.tok.lit == 'C' | 	is_c := p.tok.lit == 'C' | ||||||
| 	if is_c { | 	if is_c { | ||||||
| 		p.next() | 		p.next() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue