From 7013f6bb40d9be0b3620ab331be4d4d1b60ac477 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 29 Jun 2016 07:43:38 +0200 Subject: DIRECTOR: Lingo: Implemented 'global' keyword. Start of local/global var implementation --- engines/director/lingo/lingo-code.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engines/director/lingo/lingo-code.cpp') diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 92cb9940e0..349b51f1ca 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -424,4 +424,24 @@ void Lingo::c_procret() { g_lingo->_returning = true; } +void Lingo::c_global() { + Common::String name((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]); + + Symbol *s = g_lingo->lookupVar(name.c_str(), false); + if (s) { + if (s->global) { + warning("Redefinition of global variable %s", name.c_str()); + } else { + warning("Local variable %s declared as global", name.c_str()); + } + + return; + } + + s = g_lingo->lookupVar(name.c_str(), true, false); + s->global = true; + + g_lingo->_pc += g_lingo->calcStringAlignment(name.c_str()); +} + } -- cgit v1.2.3