s.interface_blocks.clear();
r_any_resolved = false;
s.content.visit(*this);
+ for(vector<VariableDeclaration *>::const_iterator i=redeclared_builtins.begin(); i!=redeclared_builtins.end(); ++i)
+ (*i)->source = GENERATED_SOURCE;
NodeRemover().apply(s, nodes_to_remove);
return r_any_resolved;
}
ptr = &var;
else if(!current_block->parent && ptr->interface==var.interface && ptr->type==var.type)
{
+ if(ptr->source==BUILTIN_SOURCE)
+ redeclared_builtins.push_back(&var);
+ else
+ stage->diagnostics.push_back(Diagnostic(Diagnostic::WARN, var.source, var.line,
+ format("Redeclaring non-builtin variable '%s' is deprecated", var.name)));
+
if(var.init_expression)
ptr->init_expression = var.init_expression;
if(var.layout)
resolve(literal, find_type(BasicTypeDeclaration::FLOAT, 32), false);
}
-void ExpressionResolver::visit(ParenthesizedExpression &parexpr)
-{
- TraversingVisitor::visit(parexpr);
- resolve(parexpr, parexpr.expression->type, parexpr.expression->lvalue);
-}
-
void ExpressionResolver::visit(VariableReference &var)
{
if(var.declaration)
void FunctionResolver::visit(FunctionCall &call)
{
- string arg_types;
- bool has_signature = true;
- for(NodeArray<Expression>::const_iterator i=call.arguments.begin(); (has_signature && i!=call.arguments.end()); ++i)
- {
- if((*i)->type)
- append(arg_types, ",", (*i)->type->name);
- else
- has_signature = false;
- }
-
FunctionDeclaration *declaration = 0;
- if(has_signature)
+ if(stage->types.count(call.name))
+ call.constructor = true;
+ else
{
- map<string, FunctionDeclaration *>::iterator i = stage->functions.find(format("%s(%s)", call.name, arg_types));
- declaration = (i!=stage->functions.end() ? i->second : 0);
+ string arg_types;
+ bool has_signature = true;
+ for(NodeArray<Expression>::const_iterator i=call.arguments.begin(); (has_signature && i!=call.arguments.end()); ++i)
+ {
+ if((*i)->type)
+ append(arg_types, ",", (*i)->type->name);
+ else
+ has_signature = false;
+ }
+
+ if(has_signature)
+ {
+ map<string, FunctionDeclaration *>::iterator i = stage->functions.find(format("%s(%s)", call.name, arg_types));
+ declaration = (i!=stage->functions.end() ? i->second : 0);
+ }
}
+
r_any_resolved |= (declaration!=call.declaration);
call.declaration = declaration;
vector<FunctionDeclaration *> &decls = declarations[key];
if(func.definition==&func)
{
+ if(stage_decl && stage_decl->definition)
+ {
+ if(!func.overrd)
+ stage->diagnostics.push_back(Diagnostic(Diagnostic::WARN, func.source, func.line,
+ format("Overriding function '%s' without the override keyword is deprecated", key)));
+ if(!stage_decl->definition->virtua)
+ stage->diagnostics.push_back(Diagnostic(Diagnostic::WARN, func.source, func.line,
+ format("Overriding function '%s' not declared as virtual is deprecated", key)));
+ }
stage_decl = &func;
// Set all previous declarations to use this definition.
}
else if(var.interface=="in" && current_block==&stage->content)
{
- declared_inputs.push_back(&var);
+ if(var.name.compare(0, 3, "gl_"))
+ declared_inputs.push_back(&var);
/* Try to link input variables in global scope with output variables from
previous stage. */