final tcc fixes
							parent
							
								
									cd10890258
								
							
						
					
					
						commit
						dfc7c9c00f
					
				| 
						 | 
					@ -2778,14 +2778,14 @@ fn (p mut Parser) array_init() string {
 | 
				
			||||||
		new_arr += '_no_alloc'
 | 
							new_arr += '_no_alloc'
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.gen(' })')
 | 
						p.gen(' })')
 | 
				
			||||||
	// p.gen('$new_arr($vals.len, $vals.len, sizeof($typ), ($typ[]) $c_arr );')
 | 
						// p.gen('$new_arr($vals.len, $vals.len, sizeof($typ), ($typ[$vals.len]) $c_arr );')
 | 
				
			||||||
	// Need to do this in the second pass, otherwise it goes to the very top of the out.c file
 | 
						// Need to do this in the second pass, otherwise it goes to the very top of the out.c file
 | 
				
			||||||
	if !p.first_pass() {
 | 
						if !p.first_pass() {
 | 
				
			||||||
		if i == 0 {
 | 
							//if i == 0 {
 | 
				
			||||||
			p.cgen.set_placeholder(new_arr_ph, '$new_arr($i, $i, sizeof($typ), ($typ[]) { 0 ')
 | 
								//////p.cgen.set_placeholder(new_arr_ph, '$new_arr($i, $i, sizeof($typ), ($typ[$i]) { 0 ')
 | 
				
			||||||
		} else {
 | 
							//} else {
 | 
				
			||||||
			p.cgen.set_placeholder(new_arr_ph, '$new_arr($i, $i, sizeof($typ), ($typ[]) { ')
 | 
								p.cgen.set_placeholder(new_arr_ph, '$new_arr($i, $i, sizeof($typ), ($typ[$i]) { ')
 | 
				
			||||||
		}
 | 
							//}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	typ = 'array_$typ'
 | 
						typ = 'array_$typ'
 | 
				
			||||||
	p.register_array(typ)
 | 
						p.register_array(typ)
 | 
				
			||||||
| 
						 | 
					@ -2811,6 +2811,7 @@ fn (p mut Parser) struct_init(typ string, is_c_struct_init bool) string {
 | 
				
			||||||
		p.cgen.lines[p.cgen.lines.len-1] = ''
 | 
							p.cgen.lines[p.cgen.lines.len-1] = ''
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.check(.lcbr)
 | 
						p.check(.lcbr)
 | 
				
			||||||
 | 
						no_star := typ.replace('*', '')
 | 
				
			||||||
	// `user := User{foo:bar}` => `User user = (User){ .foo = bar}`
 | 
						// `user := User{foo:bar}` => `User user = (User){ .foo = bar}`
 | 
				
			||||||
	if !ptr {
 | 
						if !ptr {
 | 
				
			||||||
		if p.is_c_struct_init {
 | 
							if p.is_c_struct_init {
 | 
				
			||||||
| 
						 | 
					@ -2836,8 +2837,8 @@ fn (p mut Parser) struct_init(typ string, is_c_struct_init bool) string {
 | 
				
			||||||
			p.check(.rcbr)
 | 
								p.check(.rcbr)
 | 
				
			||||||
			return typ
 | 
								return typ
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		no_star := typ.replace('*', '')
 | 
							//p.gen('ALLOC_INIT($no_star, {')
 | 
				
			||||||
		p.gen('ALLOC_INIT($no_star, {')
 | 
					p.gen('($no_star*)memdup(&($no_star)  {') //sizeof(Node));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mut did_gen_something := false
 | 
						mut did_gen_something := false
 | 
				
			||||||
	// Loop thru all struct init keys and assign values
 | 
						// Loop thru all struct init keys and assign values
 | 
				
			||||||
| 
						 | 
					@ -2936,7 +2937,7 @@ fn (p mut Parser) struct_init(typ string, is_c_struct_init bool) string {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.gen('}')
 | 
						p.gen('}')
 | 
				
			||||||
	if ptr {
 | 
						if ptr {
 | 
				
			||||||
		p.gen(')')
 | 
							p.gen(', sizeof($no_star))')
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	p.check(.rcbr)
 | 
						p.check(.rcbr)
 | 
				
			||||||
	p.is_struct_init = false
 | 
						p.is_struct_init = false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ mut:
 | 
				
			||||||
	imports      []string // List of all imports
 | 
						imports      []string // List of all imports
 | 
				
			||||||
	file_imports []FileImportTable // List of imports for file
 | 
						file_imports []FileImportTable // List of imports for file
 | 
				
			||||||
	flags        []string //  ['-framework Cocoa', '-lglfw3']
 | 
						flags        []string //  ['-framework Cocoa', '-lglfw3']
 | 
				
			||||||
	fn_cnt       int atomic
 | 
						fn_cnt       int //atomic
 | 
				
			||||||
	obfuscate    bool
 | 
						obfuscate    bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue