コード例 #1
0
  @Override
  public void resolve(Compiler compiler, FunctionSymbol currentFunction) {
    super.resolve(compiler, currentFunction);

    ObjectSymbol definingObject = getDefiningObject();
    if (eventTargetName.equals(definingObject.getName())) {
      // Class initialization event handlers
      if (eventName.equals("Load")) {
        definingObject.setObjectLoadEventHandler(this);
        return;
      } else if (eventName.equals("Initialize")) {
        definingObject.setInstanceInitializeEventHandler(this);
        return;
      }
    }

    // Data member bound event handler

    Symbol symbol = definingObject.getScope().lookupShallow(eventTargetName);
    if (symbol == null) {
      compiler.error(getPosition(), Error.errUndefinedSymbol, eventTargetName);
      return;
    }

    if (!(symbol instanceof DataMemberSymbol)) {
      compiler.error(getPosition(), Error.errDataMemberExpected, eventTargetName);
      return;
    }

    DataMemberSymbol targetDataMember = (DataMemberSymbol) symbol;
    Type targetDataMemberType = targetDataMember.getType();
    if (!targetDataMemberType.isObjectType()) {
      compiler.error(getPosition(), Error.errObjectTypeNeeded, targetDataMemberType.toString());
      return;
    }

    targetDataMemberType.resolve(compiler);

    Scope scope = ((ObjectType) targetDataMemberType).getScope();
    if (scope instanceof ErrorScope) {
      // Error already reported
      return;
    }

    Symbol event = ((ObjectScope) scope).lookupInObject(eventName);
    if (event == null || !(event instanceof EventSymbol)) {
      compiler.error(getPosition(), Error.errUndefinedSymbol, eventName);
    }
  }
コード例 #2
0
ファイル: DoubleType.java プロジェクト: xavieryang007/simple
  @Override
  public void generateConversion(Method m, Type toType) {
    switch (toType.getKind()) {
      default:
        // COV_NF_START
        Compiler.internalError();
        break;
        // COV_NF_END

      case BOOLEAN:
        m.generateInstrInvokestatic(CONVERSION_HELPERS_INTERNAL_NAME, "double2boolean", "(D)Z");
        break;

      case BYTE:
        m.generateInstrInvokestatic(CONVERSION_HELPERS_INTERNAL_NAME, "double2byte", "(D)B");
        break;

      case SHORT:
        m.generateInstrInvokestatic(CONVERSION_HELPERS_INTERNAL_NAME, "double2short", "(D)S");
        break;

      case INTEGER:
        m.generateInstrD2i();
        break;

      case LONG:
        m.generateInstrD2l();
        break;

      case SINGLE:
        m.generateInstrD2f();
        break;

      case DOUBLE:
        break;

      case STRING:
        generateToString(m);
        break;

      case VARIANT:
        m.generateInstrInvokestatic(
            DOUBLE_VARIANT_INTERNAL_NAME,
            "getDoubleVariant",
            "(D)L" + DOUBLE_VARIANT_INTERNAL_NAME + ";");
        break;
    }
  }