| 545 | if( tmp._nil ) throw error("Type "+t1+" already allows null"); |
| 546 | t1 = TypeMemPtr.make(tmp._obj,true); |
| 547 | continue; |
| 548 | } |
| 549 | if( match("[]") ) { |
| 550 | t1 = typeAry(t1); |
| 551 | continue; |
| 552 | } |
| 553 | break; |
| 554 | } |
| 555 | |
| 556 | // Check no forward ref |
| 557 | if( t0 != null ) return t1; |
| 558 | // Check valid forward ref, after parsing all the type extra bits. |
| 559 | // Cannot check earlier, because cannot find required 'id' until after "[]?" syntax |
| 560 | int old2 = _lexer._position; |
| 561 | String id = _lexer.matchId(); |
| 562 | _lexer._position = old2; // Reset lexer to reparse |
| 563 | if( id==null ) { |
| 564 | _lexer._position = old1; // Reset lexer to reparse |
| 565 | return null; // Not a type |
| 566 | } |
| 567 | // Yes a forward ref, so declare it |
| 568 | TYPES.put(tname,t1); |
| 569 | return t1; |
| 570 | } |
| 571 | |
| 572 | // Make an array type of t |
| 573 | private TypeMemPtr typeAry( Type t ) { |
| 574 | if( t instanceof TypeMemPtr tmp && !tmp._nil ) |
| 575 | throw error("Arrays of reference types must always be nullable"); |
| 576 | String tname = "["+t.str()+"]"; |
| 577 | Type ta = TYPES.get(tname); |
| 578 | if( ta != null ) return (TypeMemPtr)ta; |
| 579 | // Need make an array type. |
| 580 | TypeStruct ts = TypeStruct.makeAry(TypeInteger.BOT,ALIAS++,t,ALIAS++); |
| 581 | assert ts.str().equals(tname); |
| 582 | TypeMemPtr tary = TypeMemPtr.make(ts); |
| 583 | TYPES.put(tname,tary); |
| 584 | return tary; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | /** |