コード例 #1
0
ファイル: Param.java プロジェクト: danielguerber/CPIB
  @Override
  public void check(final Routine routine) throws ContextError {
    store = storeDecl.check();
    switch (flowMode.getMode()) {
      case IN:
        if (mechMode.getMode() == Modes.REF && !store.isConst()) {
          throw new ContextError(
              "IN reference parameter can not be var! Ident: " + store.getIdent(),
              storeDecl.getLine());
        }
        store.initialize();
        break;
      case INOUT:
        if (routine.getRoutineType() != RoutineTypes.PROCEDURE) {
          throw new ContextError(
              "INOUT parameter in function declaration! Ident: " + store.getIdent(),
              storeDecl.getLine());
        }
        if (store.isConst()) {
          throw new ContextError(
              "INOUT parameter can not be constant! Ident: " + store.getIdent(),
              storeDecl.getLine());
        }
        store.initialize();
        break;
      case OUT:
        if (routine.getRoutineType() != RoutineTypes.PROCEDURE) {
          throw new ContextError(
              "OUT parameter in function declaration! Ident: " + store.getIdent(),
              storeDecl.getLine());
        }
        break;
      default:
        break;
    }

    Modes changeMode = Modes.CONST;
    if (!store.isConst()) {
      changeMode = Modes.VAR;
    }

    routine.addParam(
        new Parameter(flowMode.getMode(), mechMode.getMode(), changeMode, store.getType()));

    param.check(routine);
  }