Changeset 0153c87 in mainline for uspace/app/bithenge/expression.c
 Timestamp:
 20120810T20:09:36Z (9 years ago)
 Branches:
 lfn, master
 Children:
 6be4142
 Parents:
 c9797067
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

uspace/app/bithenge/expression.c
rc9797067 r0153c87 104 104 case BITHENGE_EXPRESSION_ADD: /* fallthrough */ 105 105 case BITHENGE_EXPRESSION_SUBTRACT: /* fallthrough */ 106 case BITHENGE_EXPRESSION_MULTIPLY: 106 case BITHENGE_EXPRESSION_MULTIPLY: /* fallthrough */ 107 case BITHENGE_EXPRESSION_INTEGER_DIVIDE: /* fallthrough */ 108 case BITHENGE_EXPRESSION_MODULO: /* fallthrough */ 109 case BITHENGE_EXPRESSION_LESS_THAN: /* fallthrough */ 110 case BITHENGE_EXPRESSION_LESS_THAN_OR_EQUAL: /* fallthrough */ 111 case BITHENGE_EXPRESSION_GREATER_THAN: /* fallthrough */ 112 case BITHENGE_EXPRESSION_GREATER_THAN_OR_EQUAL: 107 113 rc = EINVAL; 108 114 if (bithenge_node_type(a) != BITHENGE_NODE_INTEGER) … … 127 133 rc = bithenge_new_integer_node(out, a_int * b_int); 128 134 break; 135 case BITHENGE_EXPRESSION_INTEGER_DIVIDE: 136 /* Integer division can behave in three major ways when the 137 * operands are signed: truncated, floored, or Euclidean. When 138 * b > 0, we give the same result as floored and Euclidean; 139 * otherwise, we currently raise an error. See 140 * https://en.wikipedia.org/wiki/Modulo_operation and its 141 * references. */ 142 if (b_int <= 0) { 143 rc = EINVAL; 144 break; 145 } 146 rc = bithenge_new_integer_node(out, 147 (a_int / b_int) + (a_int % b_int < 0 ? 1 : 0)); 148 break; 149 case BITHENGE_EXPRESSION_MODULO: 150 /* This is consistent with division; see above. */ 151 if (b_int <= 0) { 152 rc = EINVAL; 153 break; 154 } 155 rc = bithenge_new_integer_node(out, 156 (a_int % b_int) + (a_int % b_int < 0 ? b_int : 0)); 157 break; 158 case BITHENGE_EXPRESSION_LESS_THAN: 159 rc = bithenge_new_boolean_node(out, a_int < b_int); 160 break; 161 case BITHENGE_EXPRESSION_LESS_THAN_OR_EQUAL: 162 rc = bithenge_new_boolean_node(out, a_int <= b_int); 163 break; 164 case BITHENGE_EXPRESSION_GREATER_THAN: 165 rc = bithenge_new_boolean_node(out, a_int > b_int); 166 break; 167 case BITHENGE_EXPRESSION_GREATER_THAN_OR_EQUAL: 168 rc = bithenge_new_boolean_node(out, a_int >= b_int); 169 break; 129 170 case BITHENGE_EXPRESSION_EQUALS: 130 171 rc = bithenge_new_boolean_node(out, bithenge_node_equal(a, b)); 172 break; 173 case BITHENGE_EXPRESSION_NOT_EQUALS: 174 rc = bithenge_new_boolean_node(out, 175 ~bithenge_node_equal(a, b)); 131 176 break; 132 177 case BITHENGE_EXPRESSION_INVALID_BINARY_OP: … … 495 540 for (; scope && !bithenge_scope_is_barrier(scope); 496 541 scope = bithenge_scope_outer(scope)) { 542 bithenge_node_t *cur = bithenge_scope_get_current_node(scope); 543 if (!cur) 544 continue; 497 545 bithenge_node_inc_ref(self>key); 498 bithenge_node_t *cur = bithenge_scope_get_current_node(scope);499 546 int rc = bithenge_node_get(cur, self>key, out); 500 547 bithenge_node_dec_ref(cur);
Note: See TracChangeset
for help on using the changeset viewer.