2024-09-09 02:52:47 +00:00
|
|
|
/*
|
|
|
|
glsl-declaration.c
|
|
|
|
|
|
|
|
GLSL declaration handling
|
|
|
|
|
|
|
|
Copyright (C) 2024 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/alloc.h"
|
|
|
|
#include "QF/hash.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
|
|
|
#include "tools/qfcc/include/attribute.h"
|
|
|
|
#include "tools/qfcc/include/def.h"
|
|
|
|
#include "tools/qfcc/include/diagnostic.h"
|
|
|
|
#include "tools/qfcc/include/glsl-lang.h"
|
|
|
|
#include "tools/qfcc/include/shared.h"
|
|
|
|
#include "tools/qfcc/include/strpool.h"
|
|
|
|
#include "tools/qfcc/include/symtab.h"
|
|
|
|
#include "tools/qfcc/include/type.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
glsl_parse_declaration (specifier_t spec, symbol_t *sym, const type_t *array,
|
|
|
|
const expr_t *init, symtab_t *symtab)
|
|
|
|
{
|
|
|
|
if (array) {
|
|
|
|
spec.type = append_type (array, spec.type);
|
|
|
|
spec.type = find_type (spec.type);
|
|
|
|
}
|
2024-09-10 10:03:13 +00:00
|
|
|
auto attributes = glsl_optimize_attributes (spec.attributes);
|
2024-09-09 02:52:47 +00:00
|
|
|
if (sym && sym->sy_type == sy_expr) {
|
|
|
|
auto id_list = sym->expr;
|
|
|
|
if (id_list->type != ex_list) {
|
|
|
|
internal_error (id_list, "not a list");
|
|
|
|
}
|
|
|
|
for (auto id = id_list->list.head; id; id = id->next) {
|
|
|
|
if (id->expr->type != ex_symbol) {
|
|
|
|
internal_error (id_list, "not a symbol");
|
|
|
|
}
|
|
|
|
spec.sym = id->expr->symbol;
|
2024-09-10 10:03:13 +00:00
|
|
|
spec.sym = declare_symbol (spec, init, symtab);
|
|
|
|
glsl_apply_attributes (attributes, spec);
|
2024-09-09 02:52:47 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
spec.sym = sym;
|
|
|
|
if (spec.sym) {
|
2024-09-10 10:03:13 +00:00
|
|
|
spec.sym = declare_symbol (spec, init, symtab);
|
2024-09-09 02:52:47 +00:00
|
|
|
}
|
2024-09-10 10:03:13 +00:00
|
|
|
glsl_apply_attributes (attributes, spec);
|
2024-09-09 02:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
glsl_declare_field (specifier_t spec, symtab_t *symtab)
|
|
|
|
{
|
2024-09-10 10:03:13 +00:00
|
|
|
auto attributes = glsl_optimize_attributes (spec.attributes);
|
|
|
|
spec.sym = declare_field (spec, symtab);
|
|
|
|
glsl_apply_attributes (attributes, spec);
|
2024-09-09 02:52:47 +00:00
|
|
|
}
|