| 370 | | |
| 371 | | class WrappedTypeIdentifier |
| 372 | | is abstract |
| 373 | | inherits AbstractTypeIdentifier |
| 374 | | |
| 375 | | var _typeId as AbstractTypeIdentifier |
| 376 | | |
| 377 | | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| 378 | | require |
| 379 | | token.text.length |
| 380 | | ensure |
| 381 | | .name.length |
| 382 | | body |
| 383 | | base.init(token, token.text) |
| 384 | | _typeId = typeId |
| 385 | | |
| 386 | | def addMinFields |
| 387 | | base.addMinFields |
| 388 | | .addField('typeId', _typeId) |
| 389 | | |
| 390 | | get theWrappedTypeIdentifier from _typeId |
| 391 | | |
| 392 | | def _bindInt is override |
| 393 | | _typeId.bindInt |
| 394 | | base._bindInt |
| 395 | | |
| 396 | | def _bindImp is override |
| 397 | | _typeId.bindImp |
| 398 | | base._bindImp |
| 399 | | |
| 400 | | |
| 401 | | class ArrayTypeIdentifier |
| 402 | | inherits WrappedTypeIdentifier |
| 403 | | |
| 404 | | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| 405 | | base.init(token, typeId) |
| 406 | | |
| 407 | | def memberFrom(container as IContainer) as IMember? is override |
| 408 | | return container.memberForName(.theWrappedTypeIdentifier.name) |
| 409 | | |
| 410 | | def _resolveType as IType is override |
| 411 | | return ArrayType(_typeId.realType) |
| 412 | | |
| 413 | | |
| 414 | | class NilableTypeIdentifier |
| 415 | | inherits WrappedTypeIdentifier |
| 416 | | |
| 417 | | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| 418 | | base.init(token, typeId) |
| 419 | | |
| 420 | | def _resolveType as IType is override |
| 421 | | return NilableType(_typeId.realType) |
| 422 | | |
| 423 | | get name as String is override |
| 424 | | return _typeId.name + '?' |
| 425 | | |
| 426 | | def memberFrom(container as IContainer) as IMember? is override |
| 427 | | m = container.memberForName(.name[:-1]) |
| 428 | | if m inherits IType |
| 429 | | return NilableType(m) |
| 430 | | else |
| 431 | | return m |
| 432 | | |
| 433 | | |
| 434 | | class VariTypeIdentifier |
| 435 | | inherits WrappedTypeIdentifier |
| 436 | | |
| 437 | | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| 438 | | base.init(token, typeId) |
| 439 | | |
| 440 | | def _resolveType as IType is override |
| 441 | | return VariType(_typeId.realType) |
| 442 | | |
| 443 | | |
| 444 | | class TypeIdentifier |
| 445 | | inherits AbstractTypeIdentifier |
| 446 | | """ |
| 447 | | Created by CobraParser.type for identifiers found where types are |
| 448 | | expected. |
| 449 | | |
| 450 | | Cobra allows forward references so even though types are expected in |
| 451 | | places like the return type of a method, they cannot be turned into |
| 452 | | actual types until the bindInt phase (or bindImp for expressions). |
| 453 | | """ |
| 454 | | |
| 455 | | def init(token as IToken) |
| 456 | | require |
| 457 | | token.which=='ID' |
| 458 | | token.text.length |
| 459 | | ensure |
| 460 | | .name.length |
| 461 | | body |
| 462 | | base.init(token, token.text) |
| 463 | | |
| 464 | | def init(token as IToken, type as IType) |
| 465 | | require |
| 466 | | token.text.length |
| 467 | | ensure |
| 468 | | .name.length |
| 469 | | body |
| 470 | | base.init(token, token.text, type) |
| 471 | | |
| 472 | | def init(token as IToken, name as String, type as IType) |
| 473 | | """ |
| 474 | | Use this to dictate a name other than what is specified by the token. |
| 475 | | Used for QualifiedTypes, for example, that are created from multiple tokens. |
| 476 | | """ |
| 477 | | require |
| 478 | | name.length |
| 479 | | ensure |
| 480 | | .name.length |
| 481 | | body |
| 482 | | base.init(token, name, type) |
| 483 | | assert name == token.text |
| 484 | | |
| 485 | | def _resolveType as IType is override |
| | 370 | def _symbolForName(name as String) as IMember |
| | 371 | """ |
| | 372 | Returns the symbol for this nodes name or .throwError. |
| | 373 | Also, implements -correct-case or suggests it if it is off, but would have resolved. |
| | 374 | """ |
| | 400 | return symbol to ! |
| | 401 | |
| | 402 | |
| | 403 | class WrappedTypeIdentifier |
| | 404 | is abstract |
| | 405 | inherits AbstractTypeIdentifier |
| | 406 | |
| | 407 | var _typeId as AbstractTypeIdentifier |
| | 408 | |
| | 409 | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| | 410 | require |
| | 411 | token.text.length |
| | 412 | ensure |
| | 413 | .name.length |
| | 414 | body |
| | 415 | base.init(token, token.text) |
| | 416 | _typeId = typeId |
| | 417 | |
| | 418 | def addMinFields |
| | 419 | base.addMinFields |
| | 420 | .addField('typeId', _typeId) |
| | 421 | |
| | 422 | get theWrappedTypeIdentifier from _typeId |
| | 423 | |
| | 424 | def _bindInt is override |
| | 425 | _typeId.bindInt |
| | 426 | base._bindInt |
| | 427 | |
| | 428 | def _bindImp is override |
| | 429 | _typeId.bindImp |
| | 430 | base._bindImp |
| | 431 | |
| | 432 | |
| | 433 | class ArrayTypeIdentifier |
| | 434 | inherits WrappedTypeIdentifier |
| | 435 | |
| | 436 | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| | 437 | base.init(token, typeId) |
| | 438 | |
| | 439 | def memberFrom(container as IContainer) as IMember? is override |
| | 440 | return container.memberForName(.theWrappedTypeIdentifier.name) |
| | 441 | |
| | 442 | def _resolveType as IType is override |
| | 443 | return ArrayType(_typeId.realType) |
| | 444 | |
| | 445 | |
| | 446 | class NilableTypeIdentifier |
| | 447 | inherits WrappedTypeIdentifier |
| | 448 | |
| | 449 | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| | 450 | base.init(token, typeId) |
| | 451 | |
| | 452 | def _resolveType as IType is override |
| | 453 | return NilableType(_typeId.realType) |
| | 454 | |
| | 455 | get name as String is override |
| | 456 | return _typeId.name + '?' |
| | 457 | |
| | 458 | def memberFrom(container as IContainer) as IMember? is override |
| | 459 | m = container.memberForName(.name[:-1]) |
| | 460 | if m inherits IType |
| | 461 | return NilableType(m) |
| | 462 | else |
| | 463 | return m |
| | 464 | |
| | 465 | |
| | 466 | class VariTypeIdentifier |
| | 467 | inherits WrappedTypeIdentifier |
| | 468 | |
| | 469 | def init(token as IToken, typeId as AbstractTypeIdentifier) |
| | 470 | base.init(token, typeId) |
| | 471 | |
| | 472 | def _resolveType as IType is override |
| | 473 | return VariType(_typeId.realType) |
| | 474 | |
| | 475 | |
| | 476 | class TypeIdentifier |
| | 477 | inherits AbstractTypeIdentifier |
| | 478 | """ |
| | 479 | Created by CobraParser.type for identifiers found where types are |
| | 480 | expected. |
| | 481 | |
| | 482 | Cobra allows forward references so even though types are expected in |
| | 483 | places like the return type of a method, they cannot be turned into |
| | 484 | actual types until the bindInt phase (or bindImp for expressions). |
| | 485 | """ |
| | 486 | |
| | 487 | def init(token as IToken) |
| | 488 | require |
| | 489 | token.which=='ID' |
| | 490 | token.text.length |
| | 491 | ensure |
| | 492 | .name.length |
| | 493 | body |
| | 494 | base.init(token, token.text) |
| | 495 | |
| | 496 | def init(token as IToken, type as IType) |
| | 497 | require |
| | 498 | token.text.length |
| | 499 | ensure |
| | 500 | .name.length |
| | 501 | body |
| | 502 | base.init(token, token.text, type) |
| | 503 | |
| | 504 | def init(token as IToken, name as String, type as IType) |
| | 505 | """ |
| | 506 | Use this to dictate a name other than what is specified by the token. |
| | 507 | Used for QualifiedTypes, for example, that are created from multiple tokens. |
| | 508 | """ |
| | 509 | require |
| | 510 | name.length |
| | 511 | ensure |
| | 512 | .name.length |
| | 513 | body |
| | 514 | base.init(token, name, type) |
| | 515 | assert name == token.text |
| | 516 | |
| | 517 | def _resolveType as IType is override |
| | 518 | symbol = _symbolForName(.name) to dynamic |