public void handleStatement(ASTStatement node) {

    // System.out.println(node.getCode());

    // Drawing
    connector.startSnap(node.getLineNumber());

    // FIXME we'll see how this works

    // Nested scope for by macro
    SimpleNode s = (SimpleNode) node.jjtGetChild(0);

    if (s instanceof ASTStatementList) {
      System.out.println("This'll never happen");
      SymbolTable st = new SymbolTable(Global.getCurrentSymbolTable());
      st.setName("nested");
      Global.setCurrentSymbolTable(st);
      s.jjtAccept(this, null);
      Global.setCurrentSymbolTable(st.getPrevious());
    } else {

      node.jjtGetChild(0).jjtAccept(this, null);
      if (((SimpleNode) node.jjtGetChild(0)).getId() == JJTCALL) {
        ((ASTCall) (node.jjtGetChild(0))).setLineNumber(node.getLineNumber());
      }

      update(node.getLineNumber(), UPDATE_REASON_STATEMENT);
    }
    // System.out.println("endStatement");
    connector.endSnap();
  }
  public void handleFunction(ASTFunction node) {
    // Get the function's symbol table, set it's previous to the
    // calling function's, and then set it to current.
    connector.startSnap(node.getLineNumber());
    if (node.getName().equals("main")) {
      connector.addQuestion(startQuestion);
      connector.showScope("main");

    } else {
    }
    connector.endSnap();
    if (!node.getUsed()) {
      return;
    }
    SymbolTable currentSymbolTable = node.getSymbolTable();
    for (String p : node.getParameters()) {
      ByNameVariable v = new ByNameVariable();
      v.setParam();
      currentSymbolTable.put(p, v);
    }
    Global.setCurrentSymbolTable(currentSymbolTable);

    node.jjtGetChild(0).jjtAccept(this, null);
    leaveScope();
  }
 /** Convenience routine taking Strings; lookup is done in SymbolTable. */
 public Method findMethod(String name, String sig) {
   SymbolTable syms = VM.getVM().getSymbolTable();
   Symbol nameSym = syms.probe(name);
   Symbol sigSym = syms.probe(sig);
   if (nameSym == null || sigSym == null) {
     return null;
   }
   return findMethod(nameSym, sigSym);
 }
Esempio n. 4
0
 /**
  * Call this function if you want to parse expressions which involve complex numbers. This method
  * specifies "i" as the imaginary unit (0,1). Two functions re() and im() are also added for
  * extracting the real or imaginary components of a complex number respectively.
  *
  * <p>
  *
  * @since 2.3.0 alpha The functions cmod and arg are added to get the modulus and argument.
  * @since 2.3.0 beta 1 The functions complex and polar to convert x,y and r,theta to Complex.
  * @since Feb 05 added complex conjugate conj.
  */
 public void addComplex() {
   // add constants to Symbol Table
   symTab.addConstant("i", new Complex(0, 1));
   funTab.put("re", new Real());
   funTab.put("im", new Imaginary());
   funTab.put("arg", new Arg());
   funTab.put("cmod", new Abs());
   funTab.put("complex", new ComplexPFMC());
   funTab.put("polar", new Polar());
   funTab.put("conj", new Conjugate());
 }
  public void handleVarDecl(ASTVarDecl node) {
    // System.out.println("Visiting var decl");
    String name = node.getName();
    node.setLineNumber(((SimpleNode) node.jjtGetParent()).getLineNumber());
    SymbolTable s = Global.getCurrentSymbolTable();
    ArrayList<Integer> values;

    if (node.getIsArray()) {
      ByValVariable v = (ByValVariable) s.getVariable(name);
      v.setArray();
      values =
          (ArrayList<Integer>) handleArrayDeclaration((ASTArrayDeclaration) node.jjtGetChild(0));
      v.setValues(values);
    } else {
      Integer value = (Integer) node.jjtGetChild(0).jjtAccept(this, null);
      s.setValue(name, value);
    }

    // Drawing Stuff
    connector.addVariable(s.getVariable(name), name, s.getName());

    // This is a snapshot
    connector.showVar(Global.getCurrentSymbolTable().getVariable(name));
  }
Esempio n. 6
0
  /**
   * Visit a variable node. The value of the variable is obtained from the symbol table (symTab) and
   * pushed onto the stack.
   */
  public Object visit(ASTVarNode node, Object data) throws ParseException {

    // try to get the variable object
    Variable var = symTab.getVar(node.getVarName());
    if (var == null) {
      String message = "Could not evaluate " + node.getVarName() + ": ";
      throw new ParseException(message + "the variable was not found in the symbol table");
    }

    // get the variable value
    // Object temp = var.getValue();
    Object temp = var.getValue();

    if (trapNullValues && temp == null) {
      String message = "Could not evaluate " + node.getVarName() + ": ";
      throw new ParseException(message + "variable not set");
    }
    // all is fine
    // push the value on the stack
    stack.push(temp);
    return data;
  }
Esempio n. 7
0
 /**
  * Gets the object representing the variable with a given name.
  *
  * @param name the name of the variable to find.
  * @return the Variable object or null if name not found.
  * @since 2.3.0 alpha
  */
 public Variable getVar(String name) {
   return symTab.getVar(name);
 }
Esempio n. 8
0
 /**
  * Returns the value of the variable with given name.
  *
  * @param name name of the variable.
  * @return the current value of the variable.
  * @since 2.3.0 alpha
  */
 public Object getVarValue(String name) {
   return symTab.getVar(name).getValue();
 }
Esempio n. 9
0
 /**
  * Sets the value of a variable. The variable must exist beforehand.
  *
  * @param name name of the variable.
  * @param val the initial value of the variable.
  * @throws NullPointerException if the variable has not been previously created with {@link
  *     #addVariable(String,Object)} first.
  * @since 2.3.0 alpha
  * @since April 05 - throws an exception if variable unset.
  */
 public void setVarValue(String name, Object val) {
   symTab.setVarValue(name, val);
 }
Esempio n. 10
0
 /**
  * Adds a new variable to the parser as an object, or updates the value of an existing variable.
  * This must be done before parsing an expression so the parser is aware that the new variable may
  * be contained in the expression.
  *
  * @param name Name of the variable to be added
  * @param object Initial value or new value for the variable
  */
 public void addVariable(String name, Object object) {
   symTab.makeVarIfNeeded(name, object);
 }
Esempio n. 11
0
 /**
  * Removes a variable from the parser. For example after calling addStandardConstants(),
  * removeVariable("e") might be called to remove the euler constant from the set of variables.
  *
  * @return The value of the variable if it was added earlier. If the variable is not in the table
  *     of variables, <code>null</code> is returned.
  */
 public Object removeVariable(String name) {
   return symTab.remove(name);
 }
Esempio n. 12
0
 /**
  * Adds a new variable to the parser, or updates the value of an existing variable. This must be
  * done before parsing an expression so the parser is aware that the new variable may be contained
  * in the expression.
  *
  * @param name Name of the variable to be added
  * @param value Initial value or new value for the variable
  * @return Double object of the variable
  */
 public Double addVariable(String name, double value) {
   Double object = new Double(value);
   symTab.makeVarIfNeeded(name, object);
   return object;
 }
Esempio n. 13
0
 /**
  * Adds a new complex variable to the parser, or updates the value of an existing variable. This
  * must be done before parsing an expression so the parser is aware that the new variable may be
  * contained in the expression.
  *
  * @param name Name of the variable to be added
  * @param re Initial real value or new real value for the variable
  * @param im Initial imaginary value or new imaginary value for the variable
  * @return Complex object of the variable
  */
 public Complex addVariable(String name, double re, double im) {
   Complex object = new Complex(re, im);
   symTab.makeVarIfNeeded(name, object);
   return object;
 }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      address = PAConfiguration.getAddress();
      port = PAConfiguration.getPort(instantiation);
      poslAddress = PAConfiguration.getPOSL(instantiation, topic);
      rdfAddress = PAConfiguration.getRDFTaxonomy(instantiation);
      messageEndpoint = PAConfiguration.getEndpointName(instantiation, topic);
    } catch (BadConfigurationException e) {
      System.out.println(e.getMessage());
      e.printStackTrace();
      System.exit(0);
    }
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();

    try {
      System.out.println("5 Publicty Chair Servlet");
      System.out.println(response.toString());

      BufferedReader brd = request.getReader();

      String input = "";
      String message = "";

      while (!input.equals("</RuleML>")) {

        input = brd.readLine();

        message = message + input;
      }
      String[] varOrder = getVariableOrder(message);
      System.out.println("Received Message: " + message);

      //	BackwardReasoner br = new BackwardReasoner();
      //   Iterator solit =null;
      //   DefiniteClause dc = null;
      //   SymbolTable.reset();

      POSLParser pp = new POSLParser();
      // String contents = "c(a).\nc(b).\nc(c).";

      Date t1 = new GregorianCalendar().getTime();
      System.out.println(t1.getHours() + ":" + t1.getMinutes());
      // append time to contents

      System.out.println("day: " + t1.getDay());
      System.out.println("day: " + t1.getYear());
      System.out.println("day: " + t1.getMonth());

      // time
      String time = "time(" + t1.getHours() + ":integer).";
      System.out.println(time);

      String url = poslAddress;

      // String url = "http://www.jdrew.org/oojdrew/test.posl";
      String contents = "";

      // day of the week
      int day = t1.getDay();
      boolean weekday = true;

      if (day == 0 || day == 6) {
        weekday = false;
      }

      String dayOfWeek;

      if (weekday) {
        dayOfWeek = "day(weekday).";
      } else {
        dayOfWeek = "day(weekend).";
      }
      // full date
      Calendar cal = new GregorianCalendar();

      int year = cal.get(Calendar.YEAR);
      int month = cal.get(Calendar.MONTH) + 1;
      int day2 = cal.get(Calendar.DAY_OF_MONTH);

      String date;

      String day3 = "" + day2;

      if (day2 == 1 || day2 == 2 || day2 == 3 || day2 == 4 || day2 == 5 || day2 == 6 || day2 == 7
          || day2 == 8 || day2 == 9) {

        day3 = "0" + day2;
      }

      if (month == 10 || month == 11 || month == 12) date = "" + year + month + day3;
      else date = "" + year + "0" + month + day3;

      date = "date(" + date + ":integer).";

      System.out.println(date);

      String url2 = rdfAddress;
      HttpClient client2 = new HttpClient();
      GetMethod method2 = new GetMethod(url2);
      method2.setFollowRedirects(true);
      String typestr = "";
      // Execute the GET method
      int statusCode2 = client2.executeMethod(method2);
      if (statusCode2 != -1) {
        typestr = method2.getResponseBodyAsString();
      }
      System.out.println("Types: " + typestr);
      Types.reset();
      RDFSParser.parseRDFSString(typestr);

      try {
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(url);
        method.setFollowRedirects(true);

        // Execute the GET method
        int statusCode = client.executeMethod(method);
        if (statusCode != -1) {
          contents = method.getResponseBodyAsString();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      contents = contents + "\n" + time;
      contents = contents + "\n" + dayOfWeek;
      contents = contents + "\n" + date;

      BackwardReasoner br = new BackwardReasoner();
      Iterator solit = null;
      DefiniteClause dc = null;
      SymbolTable.reset();

      pp.parseDefiniteClauses(contents);

      br.loadClauses(pp.iterator());
      System.out.println("TEST");
      Iterator it = pp.iterator();
      while (it.hasNext()) {
        DefiniteClause d = (DefiniteClause) it.next();
        System.out.println("Loaded clause: " + d.toPOSLString());
      }

      br = new BackwardReasoner(br.clauses, br.oids);

      MessageParser m = new MessageParser(message);
      Element atom = null;

      try {

        atom = m.parseForContent();

      } catch (Exception e) {

        System.out.println("Invalid Message");
        // out.flush();

      }

      QueryBuilder q = new QueryBuilder(atom);
      String query = q.generateDoc();
      System.out.println("ABOUT TO INPUT THIS QUERY:" + query);
      RuleMLParser qp = new RuleMLParser();

      try {

        dc = qp.parseRuleMLQuery(query);

      } catch (Exception e) {
        System.out.println("Invalid Query");
        // out.flush();
      }

      // solit = br.iterativeDepthFirstSolutionIterator(dc);

      solit = br.iterativeDepthFirstSolutionIterator(dc);

      int varSize = 0;

      while (solit.hasNext()) {

        Vector data = new Vector();

        BackwardReasoner.GoalList gl = (BackwardReasoner.GoalList) solit.next();

        Hashtable varbind = gl.varBindings;
        javax.swing.tree.DefaultMutableTreeNode root = br.toTree();
        root.setAllowsChildren(true);

        javax.swing.tree.DefaultTreeModel dtm = new DefaultTreeModel(root);

        int i = 0;
        Object[][] rowdata = new Object[varbind.size()][2];
        varSize = varbind.size();

        Enumeration e = varbind.keys();
        while (e.hasMoreElements()) {
          Object k = e.nextElement();
          Object val = varbind.get(k);
          String ks = (String) k;
          rowdata[i][0] = ks;
          rowdata[i][1] = val;
          i++;
        }

        data.addElement(rowdata);
        String[] messages = new String[data.size()];
        MessageGenerator g =
            new MessageGenerator(
                data, varSize, messageEndpoint, m.getId(), m.getProtocol(), m.getRel(), varOrder);
        messages = g.Messages2();

        String appender = "";

        URL sender = new URL(address + ":" + port);
        HttpMessage msg = new HttpMessage(sender);
        Properties props = new Properties();

        for (int i1 = 0; i1 < data.size(); i1++) {
          System.out.println(i1 + ")" + messages[i1].toString());
          props.put("text", messages[i1].toString());
          InputStream in = msg.sendGetMessage(props);
        }
        System.out.println("NEXT MESSAGE");
      }

      MessageGenerator g =
          new MessageGenerator(
              null, varSize, messageEndpoint, m.getId(), m.getProtocol(), m.getRel());

      URL sender = new URL(address + ":" + port);
      HttpMessage msg = new HttpMessage(sender);
      Properties props = new Properties();

      String finalMessage = g.finalMessage(query);

      System.out.println(finalMessage);

      props.put("text", finalMessage);
      InputStream in = msg.sendGetMessage(props);

      System.out.println("Stop_Communication");

    } catch (Exception e) {
      System.out.println("ERROR has occured : " + e.toString());
    }
    out.close();
  }
Esempio n. 15
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;
  }
Esempio n. 16
0
 /**
  * Adds the constants pi and e to the parser. As addStandardFunctions(), this method should be
  * called immediately after the JEP object is created.
  */
 public void addStandardConstants() {
   // add constants to Symbol Table
   symTab.addConstant("pi", new Double(Math.PI));
   symTab.addConstant("e", new Double(Math.E));
 }
  public DefiniteClause buildResult(Term t) {
    if (t.getSymbol() != sym) {
      return null;
    }

    if (t.subTerms.length != 3) {
      return null;
    }

    Term p1 = t.subTerms[1].deepCopy();
    Term p2 = t.subTerms[2].deepCopy();

    if (p1.getSymbol() < 0 || p2.getSymbol() < 0) {
      return null;
    }

    String p1s = p1.getSymbolString();
    String p2s = p2.getSymbolString();

    /*
     * Kenthor - extension to support untyped number comparison
     */
    boolean allNumber = false;
    if (Pattern.matches("^[-+]?[0-9]*[.]?[0-9]*$", p1s)
        && Pattern.matches("^[-+]?[0-9]*[.]?[0-9]*$", p2s)) {
      allNumber = true;
    }

    if (allNumber
        || ((p1.getType() == Types.IFLOAT || p1.getType() == Types.IINTEGER)
            && (p2.getType() == Types.IFLOAT || p2.getType() == Types.IINTEGER))) {
      // if ((p1.getType() == Types.IFLOAT || p1.getType() == Types.IINTEGER) &&
      //    (p2.getType() == Types.IFLOAT || p2.getType() == Types.IINTEGER)) {
      double d1;
      double d2;
      try {
        d1 = Double.parseDouble(p1s);
        d2 = Double.parseDouble(p2s);
      } catch (Exception e) {
        return null;
      }
      if (d1 > d2) {
        return null;
      }
    } else if (p1.getType() == Types.ISTRING && p2.getType() == Types.ISTRING) {
      if (p1s.compareTo(p2s) > 0) {
        return null;
      }
    } else {
      return null;
    }

    Term roid =
        new Term(
            SymbolTable.internSymbol("$jdrew-lte-" + p1s + "<=" + p2s),
            SymbolTable.IOID,
            Types.ITHING);

    Vector v = new Vector();
    v.add(roid);
    v.add(p1);
    v.add(p2);

    Term atm = new Term(sym, SymbolTable.INOROLE, Types.IOBJECT, v);
    atm.setAtom(true);
    Vector v2 = new Vector();
    v2.add(atm);
    return new DefiniteClause(v2, new Vector());
  }
Esempio n. 18
0
  public Integer handleCall(ASTCall node) {
    boolean gotAQuestion = true; // FIXME HACK
    // Get the correct function head node
    ASTFunction fun = Global.getFunction(node.getName());
    System.out.println("Calling: " + fun.getName());
    // Get the parameters and put the correct values in the symbolTable
    SymbolTable st = fun.getSymbolTable();
    String name = fun.getName();
    ArrayList<String> parameters = fun.getParameters();
    JustCalling = true;
    ArrayList<Integer> args = (ArrayList<Integer>) node.jjtGetChild(0).jjtAccept(this, null);
    JustCalling = false;
    ArrayList<ASTVar> argNames = ((ASTArgs) node.jjtGetChild(0)).getArgs();
    for (int i = 0; i < args.size(); i++) {
      ByNameVariable v = (ByNameVariable) st.getVariable(parameters.get(i));
      v.setRef(argNames.get(i));

      ByNameVariable argVar = (ByNameVariable) st.getVariable(argNames.get(i).getName() + "_");
    }
    HashMap<String, String> pa = new HashMap<String, String>(); // Maps args to params
    for (int i = 0; i < parameters.size(); i++) {
      pa.put(parameters.get(i), argNames.get(i).getName());
    }
    Global.setCurrentParamToArg(pa);

    // QUESTION!!!
    callQuestion = questionFactory.getCallQuestion(name, pa);
    if (callQuestion == null) {
      System.out.println("No question");
      gotAQuestion = false;
    }
    // Drawing Stuff
    connector.addScope(new SymbolTable(null), fun.getName(), "Global", true);
    connector.startPar(); // STARTPAR
    connector.showScope(node.getName());
    if (gotAQuestion) {
      System.out.println("Adding the call question");
      connector.addQuestion(callQuestion);
    }
    connector.endPar(); // ENDPAR

    connector.endSnap();
    fun.jjtAccept(this, null); // and we gogogo

    if (gotAQuestion) {

      int answer = 0;
      try {
        answer = Global.getFunction("main").getSymbolTable().get(callQuestion.getVariable());
      } catch (Exception e) {
        System.out.println(e);
      }
      System.out.println(callQuestion.getVariable() + " is " + answer);

      if (callQuestion instanceof FIBQuestion) {
        ((FIBQuestion) callQuestion).addAnswer(answer + "");
      } else if (callQuestion instanceof TFQuestion) {
        int qa = answer;
        // Getting the value of the var at the end of the function
        String paramName = Global.getCurrentParamToArg().get(callQuestion.getVariable());
        int prevVal = 0;
        try {
          Global.getFunction("foo").getSymbolTable().get(paramName);
        } catch (Exception e) {
          System.out.println(e);
        }

        Random r = new Random();
        int choose = r.nextInt(3);
        switch (choose) {
          case 0:
            qa = callQuestion.getValue();
            System.out.println(qa + "getValue");
            ((TFQuestion) callQuestion).setAnswer(false);
            if (qa == answer) // Value is the same anyway
            {
              ((TFQuestion) callQuestion).setAnswer(true);
            }
            break;
          case 1:
          case 2:
            System.out.println(qa + "value");
            ((TFQuestion) callQuestion).setAnswer(true);
            break;
        }

        callQuestion.setText(callQuestion.getText() + qa);
      } else {
      }
    }
    connector.startSnap(Global.getFunction("main").getLineNumber());

    System.out.println("leaving call");
    return 0;
  }
Esempio n. 19
0
  /*
   * Move include file symbolTable from mst to mift
   */
  public void mvIncludeFiles(List fileList) throws IOException {
    for (Iterator<String> it1 = this.getIncludeFiles().iterator(); it1.hasNext(); ) {
      String s = it1.next();
      if (GlobalDataApp.args_flags[3] == 1) {
        if (GlobalDataSqli.MainSymbolTable.containsKey(s) == true) {
          GlobalDataSqli.MainIncludeFilesTable.put(
              s, (SymbolTable) GlobalDataSqli.MainSymbolTable.get(s));
          GlobalDataSqli.MainSymbolTable.remove(s);
        } else {
          if (GlobalDataSqli.MainIncludeFilesTable.containsKey(s) == false) {
            try {
              // file include do not exists in mst and mift
              // Create AST
              buildAST ast = new buildAST(s, 0);
              CommonTreeNodeStream nodes = ast.getNodes();

              // build walker tree to SQLI
              buildWalkerTree_sqli sqli =
                  new buildWalkerTree_sqli(
                      nodes,
                      s,
                      GlobalDataSqli.MainSymbolTable,
                      GlobalDataSqli.MainIncludeFilesTable,
                      GlobalDataSqli.MainFunctionsTable,
                      GlobalDataSqli.MainFunctionsTaintedTable,
                      GlobalDataSqli.MainTaintedTable,
                      GlobalDataSqli.mus,
                      GlobalDataSqli.MainLinesToCorrect,
                      GlobalDataSqli.MainClassesTable,
                      GlobalDataSqli.MainInstancesTable,
                      fileList);

              GlobalDataSqli.MainIncludeFilesTable.put(
                  s, (SymbolTable) GlobalDataSqli.MainSymbolTable.get(s));
              GlobalDataSqli.MainSymbolTable.remove(s);
            } catch (RecognitionException ex) {
              Logger.getLogger(SymbolTable.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        }

        SymbolTable st_aux = GlobalDataSqli.MainIncludeFilesTable.get(s);
        if (st_aux.getIncludeFiles().isEmpty() == false) {
          st_aux.mvIncludeFiles(fileList);
        }
      }

      if (GlobalDataApp.args_flags[6] == 1) {
        if (GlobalDataCodeInj.MainSymbolTable.containsKey(s) == true) {
          GlobalDataCodeInj.MainIncludeFilesTable.put(
              s, (SymbolTable) GlobalDataCodeInj.MainSymbolTable.get(s));
          GlobalDataCodeInj.MainSymbolTable.remove(s);
        } else {
          if (GlobalDataCodeInj.MainIncludeFilesTable.containsKey(s) == false) {
            // file include do not exists in mst and mift
            // Create AST
            buildAST ast = new buildAST(s, 0);
            CommonTreeNodeStream nodes = ast.getNodes();

            // build walker tree to SQLI
            buildWalkerTree_CodeInj ci =
                new buildWalkerTree_CodeInj(
                    nodes,
                    s,
                    GlobalDataCodeInj.MainSymbolTable,
                    GlobalDataCodeInj.MainIncludeFilesTable,
                    GlobalDataCodeInj.MainFunctionsTable,
                    GlobalDataCodeInj.MainFunctionsTaintedTable,
                    GlobalDataCodeInj.MainTaintedTable,
                    GlobalDataCodeInj.mus,
                    GlobalDataCodeInj.MainLinesToCorrect,
                    GlobalDataCodeInj.MainClassesTable,
                    GlobalDataCodeInj.MainInstancesTable,
                    fileList);

            GlobalDataCodeInj.MainIncludeFilesTable.put(
                s, (SymbolTable) GlobalDataCodeInj.MainSymbolTable.get(s));
            GlobalDataCodeInj.MainSymbolTable.remove(s);
          }
        }

        SymbolTable st_aux = GlobalDataCodeInj.MainIncludeFilesTable.get(s);
        if (st_aux.getIncludeFiles().isEmpty() == false) {
          st_aux.mvIncludeFiles(fileList);
        }
      }

      if (GlobalDataApp.args_flags[7] == 1) {
        if (GlobalDataXSS.MainSymbolTable.containsKey(s) == true) {
          GlobalDataXSS.MainIncludeFilesTable.put(
              s, (SymbolTable) GlobalDataXSS.MainSymbolTable.get(s));
          GlobalDataXSS.MainSymbolTable.remove(s);
        } else {
          if (GlobalDataXSS.MainIncludeFilesTable.containsKey(s) == false) {
            // file include do not exists in mst and mift
            // Create AST
            buildAST ast = new buildAST(s, 0);
            CommonTreeNodeStream nodes = ast.getNodes();

            // build walker tree to SQLI
            buildWalkerTree_XSS xss =
                new buildWalkerTree_XSS(
                    nodes,
                    s,
                    GlobalDataXSS.MainSymbolTable,
                    GlobalDataXSS.MainIncludeFilesTable,
                    GlobalDataXSS.MainFunctionsTable,
                    GlobalDataXSS.MainFunctionsTaintedTable,
                    GlobalDataXSS.MainTaintedTable,
                    GlobalDataXSS.mus,
                    GlobalDataXSS.MainLinesToCorrect,
                    GlobalDataXSS.MainClassesTable,
                    GlobalDataXSS.MainInstancesTable,
                    fileList);

            GlobalDataXSS.MainIncludeFilesTable.put(
                s, (SymbolTable) GlobalDataXSS.MainSymbolTable.get(s));
            GlobalDataXSS.MainSymbolTable.remove(s);
          }
        }

        SymbolTable st_aux = GlobalDataXSS.MainIncludeFilesTable.get(s);
        if (st_aux.getIncludeFiles().isEmpty() == false) {
          st_aux.mvIncludeFiles(fileList);
        }
      }
    }
  }
Esempio n. 20
0
 /**
  * Adds a constant. This is a variable whose value cannot be changed.
  *
  * @since 2.3.0 beta 1
  */
 public void addConstant(String name, Object value) {
   symTab.addConstant(name, value);
 }