@@ -64,7 +64,7 @@ TypeDesc osllextype (int lex);
6464OSL_NAMESPACE_EXIT
6565
6666static std::stack<TypeSpec> typespec_stack; // just for function_declaration
67- bool allowthis ;
67+ static ASTNode::ref implicit_this ;
6868
6969%}
7070
@@ -340,22 +340,21 @@ function_declaration
340340 '(' formal_params_opt ')' metadata_block_opt
341341 {
342342 if (StructSpec *s = oslcompiler->symtab().current_struct()) {
343- allowthis = true;
344343 TypeSpec t(s->name().c_str(), 0);
345- auto* args = new ASTvariable_declaration(oslcompiler, t,
346- $5);
347- $<n>$ = args ;
344+ implicit_this = new ASTvariable_declaration(oslcompiler, t,
345+ $5);
346+ $<n>$ = implicit_this.get() ;
348347 } else
349348 $<n>$ = $5;
350349 }
351350 function_body_or_just_decl
352351 {
353- allowthis = false;
354352 oslcompiler->symtab().pop (); // restore scope
355353 ASTfunction_declaration *f;
356354 f = new ASTfunction_declaration (oslcompiler,
357355 typespec_stack.top(),
358356 ustring($2), $<n>8, $9, $7);
357+ implicit_this = nullptr;
359358 oslcompiler->remember_function_decl (f);
360359 typespec_stack.pop ();
361360 $$ = f;
@@ -781,7 +780,7 @@ variable_lvalue
781780id_or_field
782781 : IDENTIFIER
783782 {
784- $$ = new ASTvariable_ref (oslcompiler, ustring($1), allowthis );
783+ $$ = new ASTvariable_ref (oslcompiler, ustring($1), implicit_this );
785784 }
786785 | variable_lvalue '.' IDENTIFIER
787786 {
@@ -936,7 +935,8 @@ type_constructor
936935function_call
937936 : IDENTIFIER '(' function_args_opt ')'
938937 {
939- $$ = new ASTfunction_call (oslcompiler, ustring($1), $3);
938+ $$ = new ASTfunction_call (oslcompiler, ustring($1), $3,
939+ nullptr, implicit_this.get());
940940 }
941941 ;
942942
0 commit comments