@@ -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
@@ -343,22 +343,21 @@ function_declaration
343343 '(' formal_params_opt ')' metadata_block_opt
344344 {
345345 if (StructSpec *s = oslcompiler->symtab().current_struct()) {
346- allowthis = true;
347346 TypeSpec t(s->name().c_str(), 0);
348- auto* args = new ASTvariable_declaration(oslcompiler, t,
349- $5);
350- $<n>$ = args ;
347+ implicit_this = new ASTvariable_declaration(oslcompiler, t,
348+ $5);
349+ $<n>$ = implicit_this.get() ;
351350 } else
352351 $<n>$ = $5;
353352 }
354353 function_body_or_just_decl
355354 {
356- allowthis = false;
357355 oslcompiler->symtab().pop (); // restore scope
358356 ASTfunction_declaration *f;
359357 f = new ASTfunction_declaration (oslcompiler,
360358 typespec_stack.top(),
361359 ustring($2), $<n>8, $9, $7);
360+ implicit_this = nullptr;
362361 oslcompiler->remember_function_decl (f);
363362 typespec_stack.pop ();
364363 $$ = f;
@@ -790,7 +789,7 @@ variable_lvalue
790789id_or_field
791790 : IDENTIFIER
792791 {
793- $$ = new ASTvariable_ref (oslcompiler, ustring($1), allowthis );
792+ $$ = new ASTvariable_ref (oslcompiler, ustring($1), implicit_this );
794793 }
795794 | variable_lvalue '.' IDENTIFIER
796795 {
@@ -945,7 +944,8 @@ type_constructor
945944function_call
946945 : IDENTIFIER '(' function_args_opt ')'
947946 {
948- $$ = new ASTfunction_call (oslcompiler, ustring($1), $3);
947+ $$ = new ASTfunction_call (oslcompiler, ustring($1), $3,
948+ nullptr, implicit_this.get());
949949 }
950950 ;
951951
0 commit comments