Parser - Prevent built-ins from being declared local
This commit is contained in:
parent
4d54ffe9e8
commit
5933179f43
1 changed files with 20 additions and 4 deletions
24
opparser.cc
24
opparser.cc
|
@ -210,7 +210,7 @@ struct T_ParserImpl_
|
||||||
|
|
||||||
M_DPARSER_( If );
|
M_DPARSER_( If );
|
||||||
M_DPARSER_( Input );
|
M_DPARSER_( Input );
|
||||||
M_DPARSER_( Local );
|
M_DPARSER_( Locals );
|
||||||
M_DPARSER_( ODebug );
|
M_DPARSER_( ODebug );
|
||||||
M_DPARSER_( Pipeline );
|
M_DPARSER_( Pipeline );
|
||||||
M_DPARSER_( Profile );
|
M_DPARSER_( Profile );
|
||||||
|
@ -684,6 +684,13 @@ void T_ParserImpl_::parseFunctionArguments(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T_String const& id( token.stringValue( ) );
|
||||||
|
if ( id == "time" || id == "width" || id == "height" ) {
|
||||||
|
errors.addNew( "cannot use built-in as argument" ,
|
||||||
|
token.location( ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto rv( function.addArgument( token ) );
|
const auto rv( function.addArgument( token ) );
|
||||||
if ( rv ) {
|
if ( rv ) {
|
||||||
T_StringBuilder esb;
|
T_StringBuilder esb;
|
||||||
|
@ -733,7 +740,7 @@ void T_ParserImpl_::parseInstructions(
|
||||||
M_CASE_( FRAMEBUFFER , Framebuffer );
|
M_CASE_( FRAMEBUFFER , Framebuffer );
|
||||||
M_CASE_( IF , If );
|
M_CASE_( IF , If );
|
||||||
M_CASE_( INPUT , Input );
|
M_CASE_( INPUT , Input );
|
||||||
M_CASE_( LOCALS , Local );
|
M_CASE_( LOCALS , Locals );
|
||||||
M_CASE_( ODBG , ODebug );
|
M_CASE_( ODBG , ODebug );
|
||||||
M_CASE_( PIPELINE , Pipeline );
|
M_CASE_( PIPELINE , Pipeline );
|
||||||
M_CASE_( PROFILE , Profile );
|
M_CASE_( PROFILE , Profile );
|
||||||
|
@ -959,11 +966,12 @@ M_INSTR_( Input )
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
M_INSTR_( Local )
|
M_INSTR_( Locals )
|
||||||
{
|
{
|
||||||
const auto ni( input.size( ) );
|
const auto ni( input.size( ) );
|
||||||
if ( ni < 2 ) {
|
if ( ni < 2 ) {
|
||||||
errors.addNew( "variable identifier expected" , input[ 0 ].location( ) );
|
errors.addNew( "variable identifier expected" ,
|
||||||
|
input[ 0 ].location( ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,6 +986,14 @@ M_INSTR_( Local )
|
||||||
token.location( ) );
|
token.location( ) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T_String const& id( token.stringValue( ) );
|
||||||
|
if ( id == "time" || id == "width" || id == "height" ) {
|
||||||
|
errors.addNew( "built-in cannot be declared local" ,
|
||||||
|
token.location( ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto prev{ instr.addVariable( token ) };
|
const auto prev{ instr.addVariable( token ) };
|
||||||
if ( !prev ) {
|
if ( !prev ) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue