From 2ea5528cd03158c19afaffa7cc2ef347f627adeb Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 27 Jul 2020 19:51:54 +0100 Subject: [PATCH] Start compiling identifiers. We'll need this if we support the "L == foobar" syntax, and besides it should really be up to the parser client whether or not they use identifiers with no function call or property reference. It also allows us to generate error messages for unknown identifers. --- common/libeval_compiler/libeval_compiler.cpp | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 51eaed6ede..aa71a09771 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -748,6 +748,29 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext ) break; } + case TR_IDENTIFIER: + { + VAR_REF* vref = aCode->createVarRef( this, node->value.str, "" ); + + if( m_errorStatus.pendingError ) + { + m_errorStatus.pendingError = true; + m_errorStatus.stage = ERROR_STATUS::CST_CODEGEN; + + if( m_errorStatus.message == "var" ) + { + m_errorStatus.message.Printf( _( "Unrecognized item '%s'" ), + node->value.str ); + m_errorStatus.srcPos = node->srcPos - strlen( node->value.str ); + } + + return false; + } + + node->uop = makeUop( TR_UOP_PUSH_VALUE, vref ); + break; + } + default: node->uop = makeUop( node->op ); break;