From 6a2250e728b640cf18a93481e86f0fcf01597a7c Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Tue, 30 Sep 2014 17:25:08 +0200 Subject: [PATCH] Support this::x for variables in this object. This is equivalent to this_program::x, but shorter to write. And, incidentally, more logical and more like other languages. --- src/language.yacc | 2 +- src/program.c | 4 ++-- src/program.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/language.yacc b/src/language.yacc index 36ac89761d..3e203f7401 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -3933,7 +3933,7 @@ inherit_specifier: string_or_identifier TOK_COLON_COLON if (e == -1) { inherit_state = state; inherit_depth = depth; - if ($1->u.sval.u.string == this_program_string) { + if ($1->u.sval.u.string == this_program_string || $1->u.sval.u.string == this_string) { inherit_state = Pike_compiler; inherit_depth = 0; e = 0; diff --git a/src/program.c b/src/program.c index 96bff847e9..b024243f6a 100644 --- a/src/program.c +++ b/src/program.c @@ -156,8 +156,8 @@ static const int lock_depth = 1; #define DECLARE #include "compilation.h" -struct pike_string *this_program_string; -static struct pike_string *this_string, *this_function_string; +struct pike_string *this_program_string, *this_string; +static struct pike_string *this_function_string; static struct pike_string *UNDEFINED_string; /* Common compiler subsystems */ diff --git a/src/program.h b/src/program.h index 65cba84b4a..5a3d6d6d13 100644 --- a/src/program.h +++ b/src/program.h @@ -50,6 +50,7 @@ PMOD_EXPORT extern struct program_state * Pike_compiler; } while(0) extern struct pike_string *this_program_string; +extern struct pike_string *this_string; /* Common compiler subsystems */ extern struct pike_string *parser_system_string; -- GitLab