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

Method GetExpression

neo/d3xp/script/Script_Compiler.cpp:1488–1671  ·  view source on GitHub ↗

============== idCompiler::GetExpression ============== */

Source from the content-addressed store, hash-verified

1486==============
1487*/
1488idVarDef *idCompiler::GetExpression( int priority ) {
1489 const opcode_t *op;
1490 const opcode_t *oldop;
1491 idVarDef *e;
1492 idVarDef *e2;
1493 const idVarDef *oldtype;
1494 etype_t type_a;
1495 etype_t type_b;
1496 etype_t type_c;
1497
1498 if ( priority == 0 ) {
1499 return GetTerm();
1500 }
1501
1502 e = GetExpression( priority - 1 );
1503 if ( token == ";" ) {
1504 // save us from searching through the opcodes unneccesarily
1505 return e;
1506 }
1507
1508 while( 1 ) {
1509 if ( ( priority == FUNCTION_PRIORITY ) && CheckToken( "(" ) ) {
1510 return ParseFunctionCall( e );
1511 }
1512
1513 // has to be a punctuation
1514 if ( immediateType ) {
1515 break;
1516 }
1517
1518 for( op = opcodes; op->name; op++ ) {
1519 if ( ( op->priority == priority ) && CheckToken( op->name ) ) {
1520 break;
1521 }
1522 }
1523
1524 if ( !op->name ) {
1525 // next token isn't at this priority level
1526 break;
1527 }
1528
1529 // unary operators act only on the left operand
1530 if ( op->type_b == &def_void ) {
1531 e = EmitOpcode( op, e, 0 );
1532 return e;
1533 }
1534
1535 // preserve our base type
1536 oldtype = basetype;
1537
1538 // field access needs scope from object
1539 if ( ( op->name[ 0 ] == '.' ) && e->TypeDef()->Inherits( &type_object ) ) {
1540 // save off what type this field is part of
1541 basetype = e->TypeDef()->def;
1542 }
1543
1544 if ( op->rightAssociative ) {
1545 // if last statement is an indirect, change it to an address of

Callers

nothing calls this directly

Calls 10

ErrorFunction · 0.50
InheritsMethod · 0.45
TypeDefMethod · 0.45
NumStatementsMethod · 0.45
SetPointerTypeMethod · 0.45
SetTypeDefMethod · 0.45
TypeMethod · 0.45
ReturnTypeMethod · 0.45
FieldTypeMethod · 0.45
PointerTypeMethod · 0.45

Tested by

no test coverage detected