1 package polyglot.types; 2 3 import java.util.Collection ; 4 import java.util.List ; 5 import java.util.Set ; 6 7 import polyglot.frontend.ExtensionInfo; 8 import polyglot.frontend.Source; 9 import polyglot.util.Position; 10 11 15 public interface TypeSystem { 16 24 void initialize(LoadedClassResolver resolver, ExtensionInfo extInfo) 25 throws SemanticException; 26 27 31 TopLevelResolver systemResolver(); 32 33 37 TableResolver parsedResolver(); 38 39 43 LoadedClassResolver loadedResolver(); 44 45 50 ImportTable importTable(String sourceName, Package pkg); 51 52 55 ImportTable importTable(Package pkg); 56 57 61 List defaultPackageImports(); 62 63 66 boolean packageExists(String name); 67 68 72 Named forName(String name) throws SemanticException; 73 74 78 Type typeForName(String name) throws SemanticException; 79 80 85 InitializerInstance initializerInstance(Position pos, ClassType container, 86 Flags flags); 87 88 95 ConstructorInstance constructorInstance(Position pos, ClassType container, 96 Flags flags, List argTypes, 97 List excTypes); 98 99 108 MethodInstance methodInstance(Position pos, ReferenceType container, 109 Flags flags, Type returnType, String name, 110 List argTypes, List excTypes); 111 112 119 FieldInstance fieldInstance(Position pos, ReferenceType container, 120 Flags flags, Type type, String name); 121 122 128 LocalInstance localInstance(Position pos, Flags flags, Type type, 129 String name); 130 131 135 ConstructorInstance defaultConstructor(Position pos, ClassType container); 136 137 138 UnknownType unknownType(Position pos); 139 140 141 UnknownPackage unknownPackage(Position pos); 142 143 144 UnknownQualifier unknownQualifier(Position pos); 145 146 153 boolean isSubtype(Type child, Type ancestor); 154 155 157 boolean descendsFrom(Type child, Type ancestor); 158 159 163 boolean isCastValid(Type fromType, Type toType); 164 165 169 boolean isImplicitCastValid(Type fromType, Type toType); 170 171 174 boolean equals(TypeObject type1, TypeObject type2); 175 176 181 boolean numericConversionValid(Type t, long value); 182 183 187 boolean numericConversionValid(Type t, Object value); 188 189 193 Type leastCommonAncestor(Type type1, Type type2) throws SemanticException; 194 195 199 boolean isCanonical(Type type); 200 201 204 boolean isAccessible(MemberInstance mi, Context context); 205 206 209 boolean classAccessible(ClassType ct, Context context); 210 211 215 boolean classAccessibleFromPackage(ClassType ct, Package pkg); 216 217 220 boolean isEnclosed(ClassType inner, ClassType outer); 221 222 226 boolean hasEnclosingInstance(ClassType inner, ClassType encl); 227 228 232 239 boolean canCoerceToString(Type t, Context c); 240 241 244 boolean isThrowable(Type type); 245 246 250 boolean isUncheckedException(Type type); 251 252 256 Collection uncheckedExceptions(); 257 258 261 PrimitiveType promote(Type t) throws SemanticException; 262 263 266 PrimitiveType promote(Type t1, Type t2) throws SemanticException; 267 268 272 276 FieldInstance findField(ReferenceType container, String name, Context c) 277 throws SemanticException; 278 279 285 FieldInstance findField(ReferenceType container, String name, ClassType currClass) 286 throws SemanticException; 287 288 293 FieldInstance findField(ReferenceType container, String name) 294 throws SemanticException; 295 296 305 MethodInstance findMethod(ReferenceType container, 306 String name, List argTypes, 307 ClassType currClass) throws SemanticException; 308 312 MethodInstance findMethod(ReferenceType container, 313 String name, List argTypes, 314 Context c) throws SemanticException; 315 316 324 ConstructorInstance findConstructor(ClassType container, List argTypes, 325 ClassType currClass) throws SemanticException; 326 327 331 ConstructorInstance findConstructor(ClassType container, List argTypes, 332 Context c) throws SemanticException; 333 334 340 ClassType findMemberClass(ClassType container, String name, ClassType currClass) 341 throws SemanticException; 342 343 347 ClassType findMemberClass(ClassType container, String name, Context c) 348 throws SemanticException; 349 350 355 ClassType findMemberClass(ClassType container, String name) 356 throws SemanticException; 357 358 362 Type superType(ReferenceType type); 363 364 368 List interfaces(ReferenceType type); 369 370 374 378 boolean throwsSubset(ProcedureInstance m1, ProcedureInstance m2); 379 380 383 boolean hasMethod(ReferenceType t, MethodInstance mi); 384 385 389 boolean hasMethodNamed(ReferenceType t, String name); 390 391 394 boolean isSameMethod(MethodInstance m1, MethodInstance m2); 395 396 399 boolean moreSpecific(ProcedureInstance m1, ProcedureInstance m2); 400 401 405 boolean hasFormals(ProcedureInstance p, List formalTypes); 406 407 411 414 NullType Null(); 415 416 419 PrimitiveType Void(); 420 421 424 PrimitiveType Boolean(); 425 426 429 PrimitiveType Char(); 430 431 434 PrimitiveType Byte(); 435 436 439 PrimitiveType Short(); 440 441 444 PrimitiveType Int(); 445 446 449 PrimitiveType Long(); 450 451 454 PrimitiveType Float(); 455 456 459 PrimitiveType Double(); 460 461 464 ClassType Object(); 465 466 469 ClassType String(); 470 471 474 ClassType Class(); 475 476 479 ClassType Throwable(); 480 481 484 ClassType Error(); 485 486 489 ClassType Exception(); 490 491 494 ClassType RuntimeException(); 495 496 499 ClassType Cloneable(); 500 501 504 ClassType Serializable(); 505 506 509 ClassType NullPointerException(); 510 511 514 ClassType ClassCastException(); 515 516 519 ClassType OutOfBoundsException(); 520 521 524 ClassType ArrayStoreException(); 525 526 529 ClassType ArithmeticException(); 530 531 534 ArrayType arrayOf(Type type); 535 536 539 ArrayType arrayOf(Position pos, Type type); 540 541 544 ArrayType arrayOf(Type type, int dims); 545 546 549 ArrayType arrayOf(Position pos, Type type, int dims); 550 551 555 Package packageForName(String name) throws SemanticException; 556 557 561 Package packageForName(Package prefix, String name) throws SemanticException; 562 563 566 Package createPackage(String name); 567 568 571 Package createPackage(Package prefix, String name); 572 573 576 Context createContext(); 577 578 579 Resolver packageContextResolver(Resolver resolver, Package pkg); 580 581 582 Resolver classContextResolver(ClassType ct); 583 584 587 LazyClassInitializer defaultClassInitializer(); 588 589 592 ParsedClassType createClassType(LazyClassInitializer init); 593 594 597 ParsedClassType createClassType(); 598 599 602 ParsedClassType createClassType(LazyClassInitializer init, Source fromSource); 603 604 607 ParsedClassType createClassType(Source fromSource); 608 609 619 Set getTypeEncoderRootSet(Type clazz); 620 621 629 public String getTransformedClassName(ClassType ct); 630 631 636 Object placeHolder(TypeObject o, java.util.Set roots); 637 638 641 Object placeHolder(TypeObject o); 642 643 646 String translatePackage(Resolver c, Package p); 647 648 651 String translatePrimitive(Resolver c, PrimitiveType t); 652 653 656 String translateArray(Resolver c, ArrayType t); 657 658 661 String translateClass(Resolver c, ClassType t); 662 663 666 String wrapperTypeString(PrimitiveType t); 667 668 672 boolean methodCallValid(MethodInstance mi, String name, List argTypes); 673 674 678 boolean callValid(ProcedureInstance mi, List argTypes); 679 680 685 List overrides(MethodInstance mi); 686 687 690 boolean canOverride(MethodInstance mi, MethodInstance mj); 691 692 696 void checkOverride(MethodInstance mi, MethodInstance mj) throws SemanticException; 697 698 702 List implemented(MethodInstance mi); 703 704 707 PrimitiveType primitiveForName(String name) throws SemanticException; 708 709 712 void checkMethodFlags(Flags f) throws SemanticException; 713 714 717 void checkLocalFlags(Flags f) throws SemanticException; 718 719 722 void checkFieldFlags(Flags f) throws SemanticException; 723 724 727 void checkConstructorFlags(Flags f) throws SemanticException; 728 729 732 void checkInitializerFlags(Flags f) throws SemanticException; 733 734 737 void checkTopLevelClassFlags(Flags f) throws SemanticException; 738 739 742 void checkMemberClassFlags(Flags f) throws SemanticException; 743 744 747 void checkLocalClassFlags(Flags f) throws SemanticException; 748 749 752 void checkAccessFlags(Flags f) throws SemanticException; 753 754 758 void checkCycles(ReferenceType t) throws SemanticException; 759 760 765 public void checkClassConformance(ClassType ct) throws SemanticException; 766 767 771 public Type staticTarget(Type t); 772 773 777 public Flags flagsForBits(int bits); 778 779 784 public Flags createNewFlag(String name, Flags print_after); 785 786 public Flags NoFlags(); 787 public Flags Public(); 788 public Flags Protected(); 789 public Flags Private(); 790 public Flags Static(); 791 public Flags Final(); 792 public Flags Synchronized(); 793 public Flags Transient(); 794 public Flags Native(); 795 public Flags Interface(); 796 public Flags Abstract(); 797 public Flags Volatile(); 798 public Flags StrictFP(); 799 } 800 | Popular Tags |