Esempio n. 1
0
    @Override
    public void endVisit(JsNameRef x, JsContext ctx) {
      String ident = x.getIdent();
      if (!x.isJsniReference()) {
        // Not a jsni reference.
        return;
      }

      JsniRef jsniRef = JsniRef.parse(ident);
      if (jsniRef == null) {
        emitError(ERR_MALFORMED_JSNI_IDENTIFIER, x.getSourceInfo(), null, ident);
        return;
      }

      Binding binding =
          resolveReference(x.getSourceInfo(), jsniRef, x.getQualifier() != null, ctx.isLvalue());

      assert !x.isResolved();
      if (!ident.equals(jsniRef.getResolvedReference())) {
        // Replace by the resolved reference (consisting of the fully qualified classname and the
        // method description including actual signature) so that dispatch everywhere is consistent
        // with the one resolved here.
        ident = jsniRef.getResolvedReference();
        JsNameRef newRef = new JsNameRef(x.getSourceInfo(), ident);
        newRef.setQualifier(x.getQualifier());
        ctx.replaceMe(newRef);
      }
      if (binding != null) {
        jsniRefs.put(ident, binding);
      }
    }
Esempio n. 2
0
 private void visitExpression(JsExpression x, JsContext ctx) {
   if (ctx.isLvalue()) {
     // Assignments to comma expressions aren't legal
     return;
   } else if (nodesInRefContext.contains(x)) {
     // Don't modify references into non-references
     return;
   } else if (!instrumentedFiles.contains(x.getSourceInfo().getFileName())) {
     return;
   } else if (x.getSourceInfo().getStartLine() == lastLine
       && (x.getSourceInfo().getFileName().equals(lastFile))) {
     return;
   }
   lastLine = x.getSourceInfo().getStartLine();
   lastFile = x.getSourceInfo().getFileName();
   endVisit(x, ctx);
 }