Ejemplo n.º 1
0
 /*
  * Print the elements of the main Map scope.
  */
 public void print(Scope scp) {
   Symbol aux1;
   Scope s;
   if (!scp.getMembers().isEmpty()) {
     System.out.println("\nScope: " + scp.getScopeName() + "\tsize=" + scp.getMembers().size());
     Iterator<Symbol> it = scp.getMembers().iterator();
     for (; it.hasNext(); ) {
       aux1 = it.next();
       if (aux1.getRootScope() != null) { // is a root of a new scope?
         s = aux1.getRootScope();
         s.print(s);
       }
     }
   } else {
     aux1 = scp.getScopeSymbol();
     System.out.println(
         "Name: "
             + aux1.getName()
             + "\t\tline: "
             + aux1.getCodeLine()
             + "\t\ttainted: "
             + aux1.getTainted()
             + "\t\tScope: "
             + aux1.getScope().getScopeName()
             + "\n");
   }
 }
Ejemplo n.º 2
0
  // ########################
  // set the scope root symbol taint
  public void printtt(String sp, Scope cp) {
    System.out.println(sp + "Scope: " + cp.getScopeName());

    Iterator<Symbol> it = cp.getMembers().iterator();
    Symbol sy;
    for (; it.hasNext(); ) {
      sy = it.next();
      if (sy.getRootScope() == null) {
        System.out.println(sp + "\tmember: " + sy.getName());
      } else {
        cp = (Scope) sy;
        sp = sp + "\t";
        cp.printtt(sp, cp);
      }
    }
  }
Ejemplo n.º 3
0
  private Boolean verifyCallItself(Scope scp, String scp_name_resolve) {
    Symbol sym;
    int i;
    Boolean equalItself = false;
    for (Iterator<Symbol> it = scp.getMembers().iterator(); it.hasNext(); ) {
      sym = it.next();
      if (sym.getRootScope() != null) {
        Scope scp_aux = (Scope) sym;
        equalItself = verifyCallItself(scp_aux, scp_name_resolve);
        if (equalItself == true) return true;
      } else {
        if (sym.getName().equals(scp_name_resolve) == true) return true;
      }
    }

    return equalItself;
  }
Ejemplo n.º 4
0
  // Resolve the name of include/require files.
  // The resolution can be a normal path or a concatenation of parts of the path (inclusive vars)
  public String resolveVarInclude(Scope scp, SymbolTable st) {
    Symbol sym;
    String ss, s, string_final = "";
    Scope scp_aux = scp;

    // verifica se o nome da var a resolver não se chama a si propria. $a = $var.$a
    // evita ciclo infinito, na resolucao.
    Boolean call_Itself = verifyCallItself(scp, scp.getScopeName());
    if (call_Itself == true) return string_final;

    for (Iterator<Symbol> it = scp_aux.getMembers().iterator(); it.hasNext(); ) {
      sym = it.next();
      if (sym.getRootScope() != null && sym.getAlfanumeric() == false) {
        scp_aux = (Scope) sym;
        try {
          ss = scp_aux.resolveVarInclude(scp_aux, st);
          string_final = string_final + ss;
        } catch (Exception e) {
        }
      } else {
        if (sym.getAlfanumeric() == true) {
          ss = sym.getName();
          if (ss.startsWith("\"") || ss.startsWith("\'")) ss = ss.substring(1, ss.length() - 1);
        }

        Boolean found = false;
        ss = sym.getName();
        for (Iterator<Symbol> it1 = st.getMembers().iterator(); it1.hasNext(); ) {
          sym = it1.next();
          s = sym.getName();
          if (s.equals(ss) == true) {
            int i = st.getMembers().indexOf(sym);
            scp_aux = (Scope) st.getMembers().get(i);
            try {
              ss = scp_aux.resolveVarInclude(scp_aux, st);
            } catch (Exception e) {
            }
            found = true;
            break;
          }
        }
        string_final = string_final + ss;
      }
    }

    try {
      // remover ' ou " do path do file
      String AA[];
      AA = string_final.split("\"");
      if (AA[0].equals(string_final)) AA = string_final.split("\'");

      String sss = "";
      for (int i = 0; i < AA.length; i++) {
        sss = sss + AA[i];
      }

      if (sss.isEmpty() == false) string_final = sss;
      // fim remover
    } catch (Exception e) {
    }
    return string_final;
  }