============== idCompiler::GetExpression ============== */
| 1486 | ============== |
| 1487 | */ |
| 1488 | idVarDef *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 |
nothing calls this directly
no test coverage detected