public void find_out_my_type() throws PlcException {
    if (type != null && !(type.is_unknown())) return;
    PhantomType l_type = null, r_type = null;

    if (_l != null) l_type = _l.getType();
    if (_r != null) r_type = _r.getType();

    if (l_type != null && l_type.equals(r_type)) type = l_type;
    else if (".internal.object".equals(l_type.get_class().getName()) && r_type != null)
      type = r_type;
    else if (".internal.object".equals(r_type.get_class().getName()) && l_type != null)
      type = l_type;
    else type = new PhTypeUnknown();
  }
  public boolean can_be_assigned_from(PhantomType src) {
    if (this.equals(src)) return true;

    if (!_is_known) return true; // variables of unknown type can eat anything
    if (!src._is_known) return false; // i know my type and he doesnt

    if (_is_void || src._is_void) return false;

    if (_is_container != src._is_container) return false;

    if (is_on_int_stack() && src.is_on_int_stack()) return true;

    if (get_class() == null) return true;

    return get_class().can_be_assigned_from(src.get_class());
  }
示例#3
0
  public String toString() {
    StringBuffer sb = new StringBuffer();

    sb.append(type.toString());
    sb.append(" ");
    sb.append(name);
    sb.append("( ");
    boolean first = true;
    for (Iterator<ArgDefinition> i = args_def.iterator(); i.hasNext(); ) {
      if (!first) sb.append(", ");
      first = false;
      sb.append(i.next().toString());
    }
    sb.append(" )");

    return sb.toString();
  }