コード例 #1
0
 /**
  * Assembles the source code.
  *
  * @param var the variable to assign the value to
  */
 @Override
 public void assemble(Register var) throws IOException {
   Expression varOrString = AssembleExpression.getRegisterOrExpression(this.string);
   if (this.maxLen != null) {
     Expression varOrMaxLen = AssembleExpression.getRegisterOrExpression(this.maxLen);
     if (this.startOffset != null) {
       Expression varOrStartOffset = AssembleExpression.getRegisterOrExpression(this.startOffset);
       ScriptParser.writeLine(
           name + " " + var + " " + varOrString + " " + varOrMaxLen + " " + varOrStartOffset);
       varOrStartOffset.setInUse(false);
     } else {
       ScriptParser.writeLine(name + " " + var + " " + varOrString + " " + varOrMaxLen);
     }
     varOrMaxLen.setInUse(false);
   } else {
     ScriptParser.writeLine(name + " " + var + " " + varOrString);
   }
   varOrString.setInUse(false);
 }
コード例 #2
0
  /**
   * Assembles the source code.
   *
   * @param var the variable to assign the value to
   */
  @Override
  public void assemble(Register var) throws IOException {
    AssembleExpression.assembleIfRequired(this.fontFace);
    String write = name + " " + var + " " + this.fontFace;

    if (this.height != null) {
      AssembleExpression.assembleIfRequired(this.height);
      write += " " + this.height;

      if (this.weight != null) {
        AssembleExpression.assembleIfRequired(this.weight);
        write += " " + this.weight;

        if (this.italic != null) {
          AssembleExpression.assembleIfRequired(this.italic);
          if (this.italic.getBooleanValue() == true) write += " /ITALIC";

          if (this.underline != null) {
            AssembleExpression.assembleIfRequired(this.underline);
            if (this.underline.getBooleanValue() == true) write += " /UNDERLINE";

            if (this.strike != null) {
              AssembleExpression.assembleIfRequired(this.strike);
              if (this.strike.getBooleanValue() == true) write += " /STRIKE";
            }
          }
        }
      }
    }

    ScriptParser.writeLine(write);
  }
コード例 #3
0
 /** Assembles the source code. */
 @Override
 public void assemble() throws IOException {
   Expression varOrIniFile = AssembleExpression.getRegisterOrExpression(this.iniFile);
   ScriptParser.writeLine(name + " " + varOrIniFile);
   varOrIniFile.setInUse(false);
 }
コード例 #4
0
 /** Assembles the source code. */
 @Override
 public void assemble() throws IOException {
   AssembleExpression.assembleIfRequired(this.value);
   ScriptParser.writeLine(name + " " + this.value);
 }
コード例 #5
0
  /**
   * Assembles the source code.
   *
   * @throws IOException
   */
  @Override
  public void assemble() throws IOException {
    // Do not assemble anything if there are no cases!
    if (this.casesList.isEmpty()) return;

    // Give each case a label.
    for (SwitchCaseStatement statement : this.casesList)
      statement.setLabel(LabelList.getCurrent().getNext());
    if (this.defaultCase != null) this.defaultCase.setLabel(LabelList.getCurrent().getNext());

    Label gotoEnd = LabelList.getCurrent().getNext();
    Label gotoStart = LabelList.getCurrent().getNext();

    // Go to the jump table which is assembled after the switch case labels and
    // statements.
    ScriptParser.writeLine("Goto " + gotoStart);

    // Using "break;" inside a switch jumps to the end.
    Label parentBreak = CodeInfo.getCurrent().setBreakLabel(gotoEnd);

    // Assemble all the statements inside the switch { }. This includes the
    // case labels.
    for (Statement statement : this.statementList) statement.assemble();

    // Restore the parent break label.
    CodeInfo.getCurrent().setBreakLabel(parentBreak);

    // Label at the top of the jump table.
    gotoStart.write();

    // Jump instructions can jump directly to the case labels.
    if (this.switchExpression instanceof JumpExpression) {
      ((JumpExpression) this.switchExpression).assemble(this.casesList);
    }
    // Other expressions we just assemble them if required and compare their
    // result.
    else {
      Expression varOrSwitchExpression =
          AssembleExpression.getRegisterOrExpression(this.switchExpression);
      for (SwitchCaseStatement caseStatement : this.casesList) {
        // Type is an integer; use IntCmp.
        if (caseStatement.getMatch().getType().equals(ExpressionType.Integer)) {
          ScriptParser.writeLine(
              String.format(
                  "IntCmp %s %s %s",
                  varOrSwitchExpression, caseStatement.getMatch(), caseStatement.getLabel()));
        }
        // Type is a string; use StrCmp or StrCmpS (if special `` quotes were
        // used).
        else {
          ScriptParser.writeLine(
              String.format(
                  "StrCmp%s %s %s %s",
                  caseStatement.getMatch().getType().equals(ExpressionType.StringSpecial)
                      ? "S"
                      : "",
                  varOrSwitchExpression,
                  caseStatement.getMatch(),
                  caseStatement.getLabel()));
        }
      }
      varOrSwitchExpression.setInUse(false);
    }

    // Default case jump.
    if (this.defaultCase != null) ScriptParser.writeLine("Goto " + this.defaultCase.getLabel());

    gotoEnd.write();
  }