Logo Search packages:      
Sourcecode: yasm version File versions  Download package

void yasm_expr_print ( const yasm_expr e,
FILE *  f 
)

Print an expression. For debugging purposes.

Parameters:
e expression
f file

Definition at line 1192 of file expr.c.

References YASM_EXPR_ADD, YASM_EXPR_AND, YASM_EXPR_DIV, YASM_EXPR_EQ, YASM_EXPR_GE, YASM_EXPR_GT, YASM_EXPR_IDENT, YASM_EXPR_LAND, YASM_EXPR_LE, YASM_EXPR_LNOT, YASM_EXPR_LOR, YASM_EXPR_LT, YASM_EXPR_MOD, YASM_EXPR_MUL, YASM_EXPR_NE, YASM_EXPR_NEG, YASM_EXPR_NOT, YASM_EXPR_OR, YASM_EXPR_SEG, YASM_EXPR_SEGOFF, YASM_EXPR_SHL, YASM_EXPR_SHR, YASM_EXPR_SIGNDIV, YASM_EXPR_SIGNMOD, YASM_EXPR_SUB, YASM_EXPR_WRT, and YASM_EXPR_XOR.

{
    char opstr[6];
    int i;

    if (!e) {
      fprintf(f, "(nil)");
      return;
    }

    switch (e->op) {
      case YASM_EXPR_ADD:
          strcpy(opstr, "+");
          break;
      case YASM_EXPR_SUB:
          strcpy(opstr, "-");
          break;
      case YASM_EXPR_MUL:
          strcpy(opstr, "*");
          break;
      case YASM_EXPR_DIV:
          strcpy(opstr, "/");
          break;
      case YASM_EXPR_SIGNDIV:
          strcpy(opstr, "//");
          break;
      case YASM_EXPR_MOD:
          strcpy(opstr, "%");
          break;
      case YASM_EXPR_SIGNMOD:
          strcpy(opstr, "%%");
          break;
      case YASM_EXPR_NEG:
          fprintf(f, "-");
          opstr[0] = 0;
          break;
      case YASM_EXPR_NOT:
          fprintf(f, "~");
          opstr[0] = 0;
          break;
      case YASM_EXPR_OR:
          strcpy(opstr, "|");
          break;
      case YASM_EXPR_AND:
          strcpy(opstr, "&");
          break;
      case YASM_EXPR_XOR:
          strcpy(opstr, "^");
          break;
      case YASM_EXPR_SHL:
          strcpy(opstr, "<<");
          break;
      case YASM_EXPR_SHR:
          strcpy(opstr, ">>");
          break;
      case YASM_EXPR_LOR:
          strcpy(opstr, "||");
          break;
      case YASM_EXPR_LAND:
          strcpy(opstr, "&&");
          break;
      case YASM_EXPR_LNOT:
          strcpy(opstr, "!");
          break;
      case YASM_EXPR_LT:
          strcpy(opstr, "<");
          break;
      case YASM_EXPR_GT:
          strcpy(opstr, ">");
          break;
      case YASM_EXPR_LE:
          strcpy(opstr, "<=");
          break;
      case YASM_EXPR_GE:
          strcpy(opstr, ">=");
          break;
      case YASM_EXPR_NE:
          strcpy(opstr, "!=");
          break;
      case YASM_EXPR_EQ:
          strcpy(opstr, "==");
          break;
      case YASM_EXPR_SEG:
          fprintf(f, "SEG ");
          opstr[0] = 0;
          break;
      case YASM_EXPR_WRT:
          strcpy(opstr, " WRT ");
          break;
      case YASM_EXPR_SEGOFF:
          strcpy(opstr, ":");
          break;
      case YASM_EXPR_IDENT:
          opstr[0] = 0;
          break;
      default:
          strcpy(opstr, " !UNK! ");
          break;
    }
    for (i=0; i<e->numterms; i++) {
      switch (e->terms[i].type) {
          case YASM_EXPR_SYM:
            fprintf(f, "%s", yasm_symrec_get_name(e->terms[i].data.sym));
            break;
          case YASM_EXPR_EXPR:
            fprintf(f, "(");
            yasm_expr_print(e->terms[i].data.expn, f);
            fprintf(f, ")");
            break;
          case YASM_EXPR_INT:
            yasm_intnum_print(e->terms[i].data.intn, f);
            break;
          case YASM_EXPR_FLOAT:
            yasm_floatnum_print(e->terms[i].data.flt, f);
            break;
          case YASM_EXPR_REG:
            /* FIXME */
            /*yasm_arch_reg_print(arch, e->terms[i].data.reg, f);*/
            break;
          case YASM_EXPR_NONE:
            break;
      }
      if (i < e->numterms-1)
          fprintf(f, "%s", opstr);
    }
}


Generated by  Doxygen 1.6.0   Back to index