Beispiel #1
0
void RegionList::insert_before_head(HeapRegion* r) {
  assert(well_formed(), "Inv");
  set_next(r, hd());
  _hd = r;
  _sz++;
  if (tl() == NULL) _tl = r;
  assert(well_formed(), "Inv");
}
Beispiel #2
0
HeapRegion* RegionList::pop() {
  assert(well_formed(), "Inv");
  HeapRegion* res = hd();
  if (res != NULL) {
    _hd = get_next(res);
    _sz--;
    set_next(res, NULL);
    if (sz() == 0) _tl = NULL;
  }
  assert(well_formed(), "Inv");
  return res;
}
Beispiel #3
0
void RegionList::delete_after(HeapRegion* r) {
  assert(well_formed(), "Precondition");
  HeapRegion* next = get_next(r);
  assert(r != NULL, "Precondition");
  HeapRegion* next_tl = get_next(next);
  set_next(r, next_tl);
  dec_sz();
  if (next == tl()) {
    assert(next_tl == NULL, "Inv");
    _tl = r;
  }
  assert(well_formed(), "Inv");
}
Beispiel #4
0
void RegionList::prepend_list(RegionList* new_list) {
  assert(well_formed(), "Precondition");
  assert(new_list->well_formed(), "Precondition");
  HeapRegion* new_tl = new_list->tl();
  if (new_tl != NULL) {
    set_next(new_tl, hd());
    _hd = new_list->hd();
    _sz += new_list->sz();
    if (tl() == NULL) _tl = new_list->tl();
  } else {
    assert(new_list->hd() == NULL && new_list->sz() == 0, "Inv");
  }
  assert(well_formed(), "Inv");
}
Beispiel #5
0
bool doc_manager::fold_neg(doc& dst) {
 start_over:
    for (unsigned i = 0; i < dst.neg().size(); ++i) {
        if (m.contains(dst.neg()[i], dst.pos()))
            return false;

        unsigned index;
        unsigned count = diff_by_012(dst.pos(), dst.neg()[i], index);
        if (count != 2) {
            if (count == 0) {
                return false;
            }
            else if (count == 3) {
                dst.neg().erase(tbvm(), i);
                --i;
            }
            else { // count == 1:
                m.set(dst.pos(), index, neg(dst.neg()[i][index]));
                dst.neg().intersect(tbvm(), dst.pos());
                goto start_over;
            }
        }
    }
    SASSERT(well_formed(dst));
    return true;
}
Beispiel #6
0
int main(int argc, char **argv) {
	int status = 0;

	if (argv[0] && argv[0][0]) {
		Prog = argv[0];
	}

	if (argc > 1) {
		int i;
		for (i = 1; i < argc; ++i) {
			if (!well_formed(argv[i])) {
				complain(argv[i], "malformed number");
				status = EXIT_FAILURE;
				continue;
			}

			say(argv[i]);
		}
	} else {
		char *line;

		while ((line = getline(stdin))) {
			if (!well_formed(line)) {
				complain(line, "malformed number");
				status = EXIT_FAILURE;
				free(line);
				continue;
			}

			say(line);
			free(line);
		}
		if (!feof(stdin)) {
			status = EXIT_FAILURE;
		}
	}

	return status;
}