Пример #1
0
 /**
  * Two RTCs are equal if both the trigger and action Symbols (respectively) are equal.
  *
  * @param other the Object to be compared to this RTC Object
  * @return true iff both RTCs have the same trigger and action Symbols.
  */
 public boolean equals(Object other) {
   return ((other instanceof RTC)
       && ((trigger == ((RTC) other).trigger)
           || ((trigger != null) && trigger.equals(((RTC) other).trigger)))
       && ((action == ((RTC) other).action)
           || ((action != null) && action.equals(((RTC) other).action))));
 }
Пример #2
0
 boolean computeSubtypeOf(Klass k) {
   // An array is a subtype of Serializable, Clonable, and Object
   Symbol name = k.getName();
   if (name != null
       && (name.equals(javaIoSerializableName())
           || name.equals(javaLangCloneableName())
           || name.equals(javaLangObjectName()))) {
     return true;
   } else {
     return false;
   }
 }
Пример #3
0
  /** Field access by name. */
  public Field findLocalField(Symbol name, Symbol sig) {
    TypeArray fields = getFields();
    int n = (int) fields.getLength();
    ConstantPool cp = getConstants();
    for (int i = 0; i < n; i += NEXT_OFFSET) {
      int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
      int sigIndex = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
      Symbol f_name = cp.getSymbolAt(nameIndex);
      Symbol f_sig = cp.getSymbolAt(sigIndex);
      if (name.equals(f_name) && sig.equals(f_sig)) {
        return newField(i);
      }
    }

    return null;
  }
Пример #4
0
  private static boolean FindSubst(Symbol l1, Symbol l2, ArrayList<Substitution> bindings) {
    Symbol aux1 = (Symbol) l1.clone();
    Symbol aux2 = (Symbol) l2.clone();

    aux1.makeGround(bindings);
    aux2.makeGround(bindings);

    if (!aux1.isGrounded()) {
      if (!aux1.equals(aux2)) {
        bindings.add(new Substitution(aux1, aux2));
      }
    } else if (!aux2.isGrounded()) {
      bindings.add(new Substitution(aux2, aux1));
    } else {
      return aux1.equals(aux2);
    }

    return true;
  }
Пример #5
0
 public boolean equals(Object obj) {
   if (!obj.getClass().equals(this.getClass())) return false;
   StateTreeString s = (StateTreeString) obj;
   boolean ans =
       (state.equals(s.state)
           && i.equals(s.i)
           && o.equals(s.o)
           && align[0] == s.align[0]
           && align[1] == s.align[1]
           && align[2] == s.align[2]
           && align[3] == s.align[3]);
   return ans;
 }
Пример #6
0
  // refer to compute_modifier_flags in VM code.
  public long computeModifierFlags() {
    long access = getAccessFlags();
    // But check if it happens to be member class.
    TypeArray innerClassList = getInnerClasses();
    int length = (innerClassList == null) ? 0 : (int) innerClassList.getLength();
    if (length > 0) {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0, "just checking");
      }
      for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) {
        int ioff =
            innerClassList.getShortAt(i + InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
        // 'ioff' can be zero.
        // refer to JVM spec. section 4.7.5.
        if (ioff != 0) {
          // only look at classes that are already loaded
          // since we are looking for the flags for our self.
          Oop classInfo = getConstants().getObjAt(ioff);
          Symbol name = null;
          if (classInfo instanceof Klass) {
            name = ((Klass) classInfo).getName();
          } else if (classInfo instanceof Symbol) {
            name = (Symbol) classInfo;
          } else {
            throw new RuntimeException("should not reach here");
          }

          if (name.equals(getName())) {
            // This is really a member class
            access =
                innerClassList.getShortAt(
                    i + InnerClassAttributeOffset.innerClassAccessFlagsOffset);
            break;
          }
        }
      } // for inner classes
    }

    // Remember to strip ACC_SUPER bit
    return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS;
  }
Пример #7
0
  private boolean isInInnerClasses(Symbol sym, boolean includeLocals) {
    TypeArray innerClassList = getInnerClasses();
    int length = (innerClassList == null) ? 0 : (int) innerClassList.getLength();
    if (length > 0) {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0, "just checking");
      }
      for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) {
        int ioff =
            innerClassList.getShortAt(i + InnerClassAttributeOffset.innerClassInnerClassInfoOffset);
        // 'ioff' can be zero.
        // refer to JVM spec. section 4.7.5.
        if (ioff != 0) {
          Oop iclassInfo = getConstants().getObjAt(ioff);
          Symbol innerName = null;
          if (iclassInfo instanceof Klass) {
            innerName = ((Klass) iclassInfo).getName();
          } else if (iclassInfo instanceof Symbol) {
            innerName = (Symbol) iclassInfo;
          } else {
            throw new RuntimeException("should not reach here");
          }

          Symbol myname = getName();
          int ooff =
              innerClassList.getShortAt(
                  i + InnerClassAttributeOffset.innerClassOuterClassInfoOffset);
          // for anonymous classes inner_name_index of InnerClasses
          // attribute is zero.
          int innerNameIndex =
              innerClassList.getShortAt(i + InnerClassAttributeOffset.innerClassInnerNameOffset);
          // if this is not a member (anonymous, local etc.), 'ooff' will be zero
          // refer to JVM spec. section 4.7.5.
          if (ooff == 0) {
            if (includeLocals) {
              // does it looks like my local class?
              if (innerName.equals(sym) && innerName.asString().startsWith(myname.asString())) {
                // exclude anonymous classes.
                return (innerNameIndex != 0);
              }
            }
          } else {
            Oop oclassInfo = getConstants().getObjAt(ooff);
            Symbol outerName = null;
            if (oclassInfo instanceof Klass) {
              outerName = ((Klass) oclassInfo).getName();
            } else if (oclassInfo instanceof Symbol) {
              outerName = (Symbol) oclassInfo;
            } else {
              throw new RuntimeException("should not reach here");
            }

            // include only if current class is outer class.
            if (outerName.equals(myname) && innerName.equals(sym)) {
              return true;
            }
          }
        }
      } // for inner classes
      return false;
    } else {
      return false;
    }
  }