Пример #1
0
  /**
   * Indicates whether any declarations matching <code>name</code> in enclosing (etc.) scopes
   *
   * <p>are hidden by a declaration in this scope. <br>
   * <strong>note:</strong> you will generally use <code>searchLocalScope</code> to do a
   *
   * <p>proper search for matches in this scope prior to using this method.
   *
   * @param name the id to check
   * @param flags any lookup flags - if the lookup is taking place for an id with an
   *     <p><em>elaborated type specifier</em>, the id will not be hidden by matches in this scope.
   */
  protected boolean hidden(String name, LFlags flags) {

    return (!(flags.contains(Cpp_LFlags.ELABTYPE) || scope.get(name) == null));
  }
Пример #2
0
  /**
   * C++ - specific routine for qualified id lookup.
   *
   * <ul>
   *   ISO notes:
   *   <li>3.4.3-4 (global scope) case taken care of by <code>CTSymbolTable</code> before this
   *       routine is called
   * </ul>
   *
   * @param name the scoped name (qualified id) to resolve
   * @param flags any additional constraints on the lookup are indicated here
   * @throws UndefinedSymbolException if any part of the qualifier doesn't resolve
   */
  protected DeclarationSet qualifiedLookup(ScopedName name, LFlags flags)
      throws UndefinedSymbolException {

    d.msg(
        Debug.COMPILE, ">>>welcome to common_sh qualified lookup, in " + this.getClass().getName());

    // 3.4.3.4 (global scope) case taken care of before this method is called

    // break references up

    // current scope is local scope

    // for each reference

    // search for reference in current scope

    // if found, new current scope is the namespace or class referred to

    // this test may be overkill - is this method ever called outside of

    // the CTSymbolTable and other ScopeHolders ?

    if (!name.is_qualified()) Assert.apology(NOT_QUALIFIED, name.getName());

    DeclarationSet matches = unqualifiedLookup(name, flags);

    if (name.index.terminal()) { // reached terminal id in scoped name

      name.index.reset();

      return matches;

    } else { // continue along qualifiers

      if (matches.isEmpty()) {

        throw new UndefinedSymbolException(name);
      }

      // getScopeHolder will check for multiple matches or

      // non-scope-holder match

      CommonSH msh = (CommonSH) matches.getScopeHolder();

      name.index.advance();

      // lookup for any id after the first qualifier is constrained by

      // its qualifier (3.4.3-3)

      // ** TODO ** special cases for destructor names and

      // conversion-type-ids (3.4.3.1-1)

      flags.set(Cpp_LFlags.QUALIFIED);

      return msh.qualifiedLookup(name, flags);
    }

    // 3.4.3-3

    // any name coming after a qualified name in a declaration is looked

    // up in the scope of the qualified name's class or namespace

    // anything before the qualified name is as normal

    // - This is handled by CTSymbolTable and the algorithm in this method

    // 3.4.3.1

    // 1. a conversion-type-id of an operator-function-id is looked up

    // both in the scope of the class and in the context in which

    // the entire postfix-expression occurs and shall refer to the same

    // type in both contexts

    // - the approach currently taken is that since they 'shall refer

    //   to the same type', we can just look for it from the class scope.

    //   We don't need to check that the type is visible and equivalent

    //   in the pf-exp context.

    // 2. destructor name is looked up as specified in 3.4.3-5

    // - still need to detangle this one. Approach is to handle up

    //   front via lookup context flag QUALDEST.

  }