From: Mikko Rasa Date: Sat, 13 Mar 2021 19:36:56 +0000 (+0200) Subject: Resolve constructors in FunctionResolver X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=2e0ed3f7d23f09de7b4b09c2f132c316ce703d9a;hp=a4cd67f1c9f1f375bacacfbb421d40f78a22644b;p=libs%2Fgl.git Resolve constructors in FunctionResolver --- diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index 9dff1e60..11116b11 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -937,22 +937,28 @@ bool FunctionResolver::apply(Stage &s) void FunctionResolver::visit(FunctionCall &call) { - string arg_types; - bool has_signature = true; - for(NodeArray::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::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::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::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; diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index a2e3296d..8f2160a6 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -575,7 +575,6 @@ RefPtr Parser::parse_function_call(const VariableReference &var) { RefPtr call = create_node(); call->name = var.name; - call->constructor = is_type(call->name); call->oper = &Operator::get_operator("(", Operator::POSTFIX); tokenizer.expect("("); while(tokenizer.peek_token()!=")")