mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-24 04:41:25 +00:00
Merge branch 'master' of github.com:graphitemaster/gmqcc
This commit is contained in:
commit
1ca3e72417
5 changed files with 61 additions and 51 deletions
63
ast.c
63
ast.c
|
@ -1391,18 +1391,8 @@ bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
|
|||
v->cvq = self->cvq;
|
||||
self->ir_v = v;
|
||||
|
||||
if (self->setter) {
|
||||
if (!ast_global_codegen(self->setter, func->owner, false) ||
|
||||
!ast_function_codegen(self->setter->constval.vfunc, func->owner) ||
|
||||
!ir_function_finalize(self->setter->constval.vfunc->ir_func))
|
||||
return false;
|
||||
}
|
||||
if (self->getter) {
|
||||
if (!ast_global_codegen(self->getter, func->owner, false) ||
|
||||
!ast_function_codegen(self->getter->constval.vfunc, func->owner) ||
|
||||
!ir_function_finalize(self->getter->constval.vfunc->ir_func))
|
||||
return false;
|
||||
}
|
||||
if (!ast_generate_accessors(self, func->owner))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
error: /* clean up */
|
||||
|
@ -1410,6 +1400,55 @@ error: /* clean up */
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ast_generate_accessors(ast_value *self, ir_builder *ir)
|
||||
{
|
||||
size_t i;
|
||||
bool warn = OPTS_WARN(WARN_USED_UNINITIALIZED);
|
||||
if (!self->setter || !self->getter)
|
||||
return true;
|
||||
for (i = 0; i < self->expression.count; ++i) {
|
||||
if (!self->ir_values) {
|
||||
compile_error(ast_ctx(self), "internal error: no array values generated for `%s`", self->name);
|
||||
return false;
|
||||
}
|
||||
if (!self->ir_values[i]) {
|
||||
compile_error(ast_ctx(self), "internal error: not all array values have been generated for `%s`", self->name);
|
||||
return false;
|
||||
}
|
||||
if (self->ir_values[i]->life) {
|
||||
compile_error(ast_ctx(self), "internal error: function containing `%s` already generated", self->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
options_set(opts_warn, WARN_USED_UNINITIALIZED, false);
|
||||
if (self->setter) {
|
||||
if (!ast_global_codegen (self->setter, ir, false) ||
|
||||
!ast_function_codegen(self->setter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(self->setter->constval.vfunc->ir_func))
|
||||
{
|
||||
compile_error(ast_ctx(self), "internal error: failed to generate setter for `%s`", self->name);
|
||||
options_set(opts_warn, WARN_USED_UNINITIALIZED, warn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (self->getter) {
|
||||
if (!ast_global_codegen (self->getter, ir, false) ||
|
||||
!ast_function_codegen(self->getter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(self->getter->constval.vfunc->ir_func))
|
||||
{
|
||||
compile_error(ast_ctx(self), "internal error: failed to generate getter for `%s`", self->name);
|
||||
options_set(opts_warn, WARN_USED_UNINITIALIZED, warn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < self->expression.count; ++i) {
|
||||
vec_free(self->ir_values[i]->life);
|
||||
}
|
||||
options_set(opts_warn, WARN_USED_UNINITIALIZED, warn);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
||||
{
|
||||
ir_function *irf;
|
||||
|
|
1
ast.h
1
ast.h
|
@ -626,6 +626,7 @@ void ast_function_delete(ast_function*);
|
|||
const char* ast_function_label(ast_function*, const char *prefix);
|
||||
|
||||
bool ast_function_codegen(ast_function *self, ir_builder *builder);
|
||||
bool ast_generate_accessors(ast_value *asvalue, ir_builder *ir);
|
||||
|
||||
/* Expression union
|
||||
*/
|
||||
|
|
2
gmqcc.h
2
gmqcc.h
|
@ -946,4 +946,6 @@ extern uint32_t opts_flags [1 + (COUNT_FLAGS / 32)];
|
|||
extern uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)];
|
||||
extern uint32_t opts_optimization[1 + (COUNT_OPTIMIZATIONS / 32)];
|
||||
|
||||
void options_set(uint32_t *flags, size_t idx, bool on);
|
||||
|
||||
#endif
|
||||
|
|
2
main.c
2
main.c
|
@ -169,7 +169,7 @@ static bool options_long_gcc(const char *optname, int *argc_, char ***argv_, cha
|
|||
return options_long_witharg_all(optname, argc_, argv_, out, 1, false);
|
||||
}
|
||||
|
||||
static void options_set(uint32_t *flags, size_t idx, bool on)
|
||||
void options_set(uint32_t *flags, size_t idx, bool on)
|
||||
{
|
||||
longbit lb = LONGBIT(idx);
|
||||
#if 0
|
||||
|
|
44
parser.c
44
parser.c
|
@ -4591,25 +4591,9 @@ bool parser_finish(const char *output)
|
|||
if (!ast_istype(parser->globals[i], ast_value))
|
||||
continue;
|
||||
asvalue = (ast_value*)(parser->globals[i]);
|
||||
if (asvalue->setter) {
|
||||
if (!ast_global_codegen(asvalue->setter, ir, false) ||
|
||||
!ast_function_codegen(asvalue->setter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->setter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate setter for %s\n", asvalue->name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (asvalue->getter) {
|
||||
if (!ast_global_codegen(asvalue->getter, ir, false) ||
|
||||
!ast_function_codegen(asvalue->getter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->getter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate getter for %s\n", asvalue->name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
if (!ast_generate_accessors(asvalue, ir)) {
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < vec_size(parser->fields); ++i) {
|
||||
|
@ -4620,25 +4604,9 @@ bool parser_finish(const char *output)
|
|||
continue;
|
||||
if (asvalue->expression.vtype != TYPE_ARRAY)
|
||||
continue;
|
||||
if (asvalue->setter) {
|
||||
if (!ast_global_codegen(asvalue->setter, ir, false) ||
|
||||
!ast_function_codegen(asvalue->setter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->setter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate setter for %s\n", asvalue->name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (asvalue->getter) {
|
||||
if (!ast_global_codegen(asvalue->getter, ir, false) ||
|
||||
!ast_function_codegen(asvalue->getter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->getter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate getter for %s\n", asvalue->name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
if (!ast_generate_accessors(asvalue, ir)) {
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < vec_size(parser->functions); ++i) {
|
||||
|
|
Loading…
Reference in a new issue