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