MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ParseValue

Method ParseValue

neo/game/script/Script_Compiler.cpp:1278–1320  ·  view source on GitHub ↗

============ idCompiler::ParseValue Returns the def for the current token ============ */

Source from the content-addressed store, hash-verified

1276============
1277*/
1278idVarDef *idCompiler::ParseValue( void ) {
1279 idVarDef *def;
1280 idVarDef *namespaceDef;
1281 idStr name;
1282
1283 if ( immediateType == &type_entity ) {
1284 // if an immediate entity ($-prefaced name) then create or lookup a def for it.
1285 // when entities are spawned, they'll lookup the def and point it to them.
1286 def = gameLocal.program.GetDef( &type_entity, "$" + token, &def_namespace );
1287 if ( !def ) {
1288 def = gameLocal.program.AllocDef( &type_entity, "$" + token, &def_namespace, true );
1289 }
1290 NextToken();
1291 return def;
1292 } else if ( immediateType ) {
1293 // if the token is an immediate, allocate a constant for it
1294 return ParseImmediate();
1295 }
1296
1297 ParseName( name );
1298 def = LookupDef( name, basetype );
1299 if ( !def ) {
1300 if ( basetype ) {
1301 Error( "%s is not a member of %s", name.c_str(), basetype->TypeDef()->Name() );
1302 } else {
1303 Error( "Unknown value \"%s\"", name.c_str() );
1304 }
1305 // if namespace, then look up the variable in that namespace
1306 } else if ( def->Type() == ev_namespace ) {
1307 while( def->Type() == ev_namespace ) {
1308 ExpectToken( "::" );
1309 ParseName( name );
1310 namespaceDef = def;
1311 def = gameLocal.program.GetDef( NULL, name, namespaceDef );
1312 if ( !def ) {
1313 Error( "Unknown value \"%s::%s\"", namespaceDef->GlobalName(), name.c_str() );
1314 }
1315 }
1316 //def = LookupDef( name, basetype );
1317 }
1318
1319 return def;
1320}
1321
1322/*
1323============

Callers

nothing calls this directly

Calls 8

ErrorFunction · 0.50
GetDefMethod · 0.45
AllocDefMethod · 0.45
c_strMethod · 0.45
NameMethod · 0.45
TypeDefMethod · 0.45
TypeMethod · 0.45
GlobalNameMethod · 0.45

Tested by

no test coverage detected