Esempio n. 1
0
  /** Returns the id for a function name. */
  public int getFunctionId(String name) {
    if (!isStrict()) name = name.toLowerCase(Locale.ENGLISH);

    if (name.startsWith("\\")) {
      // php/0m18
      name = name.substring(1);
    }

    int id = _functionNameMap.get(name);

    if (id >= 0) return id;

    synchronized (_functionNameMap) {
      id = _functionNameMap.get(name);

      if (id >= 0) return id;

      // 0 is used for an undefined function
      // php/1p0g
      id = _functionNameMap.size() + 1;

      _functionNameMap.put(name, id);

      extendFunctionMap(name, id);
    }

    return id;
  }
Esempio n. 2
0
  /** Returns the id for a class name. */
  public int getClassId(String className) {
    int id = _classNameMap.get(className);

    if (id >= 0) return id;

    if (className.startsWith("\\")) className = className.substring(1);

    id = _classNameMap.get(className);

    if (id >= 0) return id;

    synchronized (_classNameMap) {
      String name = className.toLowerCase(Locale.ENGLISH);

      id = _classNameMap.get(name);

      if (id >= 0) {
        _classNameMap.put(className, id);

        return id;
      }

      id = _classNameMap.size();

      if (_classDefMap.length <= id) {
        String[] classNames = new String[id + 256];
        System.arraycopy(_classNames, 0, classNames, 0, _classNames.length);
        _classNames = classNames;

        ClassDef[] classDefMap = new ClassDef[_classNames.length];
        System.arraycopy(_classDefMap, 0, classDefMap, 0, _classDefMap.length);
        _classDefMap = classDefMap;

        QuercusClass[] classCacheMap = new QuercusClass[_classNames.length];
        System.arraycopy(_classCacheMap, 0, classCacheMap, 0, _classCacheMap.length);
        _classCacheMap = classCacheMap;
      }

      _classNames[id] = className;

      // _classMap[id] = new UndefinedClass(name);

      _classNameMap.put(className, id);
      _classNameMap.put(name, id);
    }

    return id;
  }
Esempio n. 3
0
  /** Returns the id for a constant */
  public int getConstantId(StringValue name) {
    int id = _constantNameMap.get(name);

    if (id >= 0) return id;

    synchronized (_constantNameMap) {
      id = _constantNameMap.get(name);

      if (id >= 0) return id;

      // php/313j
      id = _constantNameMap.size() + 1;

      if (_classDefMap.length <= id) {
        Value[] constantMap = new Value[id + 256];
        System.arraycopy(_constantMap, 0, constantMap, 0, _constantMap.length);
        _constantMap = constantMap;

        Value[] constantNameList = new Value[id + 256];
        System.arraycopy(_constantNameList, 0, constantNameList, 0, _constantNameList.length);
        _constantNameList = constantNameList;

        int[] constantLowerMap = new int[_constantMap.length];
        System.arraycopy(_constantLowerMap, 0, constantLowerMap, 0, _constantLowerMap.length);
        _constantLowerMap = constantLowerMap;
      }

      // XXX: i18n
      _constantNameList[id] = name;

      // php/1a0g, php/1d06
      _constantNameMap.put(name, id);

      // php/050a - only case-insensitive constants should add lower case,
      // i.e. use addLowerConstantId
    }

    return id;
  }
Esempio n. 4
0
 /** Returns the number of defined constants */
 public int getConstantIdCount() {
   return _constantNameMap.size();
 }
Esempio n. 5
0
 /** Returns the number of classes */
 public int getClassIdCount() {
   return _classNameMap.size();
 }
Esempio n. 6
0
 /** Returns the number of functions */
 public int getFunctionIdCount() {
   return _functionNameMap.size();
 }