コード例 #1
0
ファイル: Comparator.java プロジェクト: blickly/ptii
  /**
   * Generate fire code. Read the <code>fireBlock</code> from Comparator.c, replace macros with
   * their values and return the processed code block.
   *
   * @return The processed code string.
   * @exception IllegalActionException If the code stream encounters an error in processing the
   *     specified code block(s).
   */
  protected String _generateFireCode() throws IllegalActionException {
    super._generateFireCode();
    ptolemy.actor.lib.logic.Comparator actor = (ptolemy.actor.lib.logic.Comparator) getComponent();

    String comparison = actor.comparison.getExpression();

    if (comparison.equals(">")) {
      _codeStream.appendCodeBlock("GTBlock");
    } else if (comparison.equals(">=")) {
      _codeStream.appendCodeBlock("GEBlock");
    } else if (comparison.equals("<")) {
      _codeStream.appendCodeBlock("LTBlock");
    } else if (comparison.equals("<=")) {
      _codeStream.appendCodeBlock("LEBlock");
    } else if (comparison.equals("==")) {
      _codeStream.appendCodeBlock("EQBlock");
    }
    return processCode(_codeStream.toString());
  }
コード例 #2
0
ファイル: Equals.java プロジェクト: blickly/ptii
  /**
   * Generate fire code. Read the <code>fireBlock</code> from Equals.c, replace macros with their
   * values and return the processed code block.
   *
   * @return The processed code string.
   * @exception IllegalActionException If the code stream encounters an error in processing the
   *     specified code block(s).
   */
  protected String _generateFireCode() throws IllegalActionException {
    super._generateFireCode();
    ptolemy.actor.lib.logic.Equals actor = (ptolemy.actor.lib.logic.Equals) getComponent();

    String type = "";
    type = codeGenType(actor.input.getType());
    if (!isPrimitive(type)) {
      type = "Token";
    }

    _codeStream.appendCodeBlock("fireBlockOpen");
    ArrayList args = new ArrayList();
    args.add(Integer.valueOf(0));
    args.add(Integer.valueOf(1));
    for (int i = 0; i < actor.input.getWidth() - 1; i++) {
      args.set(0, Integer.valueOf(i));
      args.set(1, Integer.valueOf(i + 1));
      _codeStream.appendCodeBlock(type + "EqualsBlock", args);
    }
    return processCode(_codeStream.toString());
  }
コード例 #3
0
ファイル: NonStrictTest.java プロジェクト: ptII/ptII
  /**
   * Generate fire code. The method reads in <code>fireBlock</code> from Test.c, replaces macros
   * with their values and returns the processed code block.
   *
   * @return The generated code.
   * @exception IllegalActionException If the code stream encounters an error in processing the
   *     specified code block(s).
   */
  protected String _generateFireCode() throws IllegalActionException {
    super._generateFireCode();

    ptolemy.actor.lib.NonStrictTest actor = (ptolemy.actor.lib.NonStrictTest) getComponent();

    ArrayList args = new ArrayList();
    args.add(Integer.valueOf(0));
    String multiChannel = "";
    Type inputType = actor.input.getType();
    String inputTypeString = "";
    String blockName = "Block";

    if (actor.input.getWidth() > 1) {
      // If we have multiple inputs, use different blocks
      multiChannel = "MultiChannel";
    }

    inputTypeString = codeGenType(inputType);
    if (isPrimitive(inputType)) {
      blockName = inputTypeString + blockName;
    } else {
      if (multiChannel.length() == 0 && (actor.input.getType() instanceof ArrayType)) {
        blockName = "Array" + blockName;
      } else {
        blockName = "Token" + blockName;
      }
      args.add(inputTypeString);
    }

    for (int i = 0; i < actor.input.getWidth(); i++) {
      args.set(0, Integer.valueOf(i));

      _codeStream.appendCodeBlock(blockName + multiChannel, args);
    }
    return processCode(_codeStream.toString());
  }