001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    package escjava.tc;
004    
005    import javafe.ast.ModifierPragmaVec;
006    import escjava.ast.TagConstants;
007    
008    import javafe.tc.TypeSig;
009    import javafe.util.Info;
010    
011    public class TypeCheck extends javafe.tc.TypeCheck
012    {
013        /**
014         * Creates a singleton instance of this class, and sets the <code>inst</code>
015         * field to this instance. Only one instance should be created.  Also initializes
016         * {@link javafe.tc.PrepTypeDeclaration}.
017         */
018        public TypeCheck() {
019            inst = this;
020            new escjava.tc.PrepTypeDeclaration();
021        }
022    
023        /**
024         * Called to obtain the algorithm for performing name resolution and type
025         * checking.
026         *
027         * @return an instance of <code>escjava.tc.FlowInsensitiveChecks</code>.
028         */
029        public javafe.tc.FlowInsensitiveChecks makeFlowInsensitiveChecks() {
030            return new escjava.tc.FlowInsensitiveChecks();
031        }
032    
033        /**
034         * Override {@link javafe.tc.TypeCheck#canAccess} to account for
035         * <code>spec_public</code>.
036         */
037        public boolean canAccess(TypeSig from, TypeSig target,
038                                 int modifiers,
039                                 ModifierPragmaVec pmodifiers) {
040            if (super.canAccess(from, target, modifiers, pmodifiers))
041                return true;
042    
043            if (!escjava.tc.FlowInsensitiveChecks.inAnnotation)
044                return false;
045    
046            if (pmodifiers == null)
047                return false;
048    
049            for (int i = 0; i < pmodifiers.size(); i++) {
050                if (pmodifiers.elementAt(i).getTag() == TagConstants.SPEC_PUBLIC)
051                    return true;
052            }
053    
054            return false;
055        }
056    } // end of class TypeCheck
057    
058    /*
059     * Local Variables:
060     * Mode: Java
061     * fill-column: 85
062     * End:
063     */