void VariableScope::flush_to_heap_internal(STATE) {
    if(isolated()) return;

    Tuple* new_locals = Tuple::create(state, number_of_locals());

    for(int i = 0; i < number_of_locals(); i++) {
      new_locals->put(state, i, locals()[i]);
    }

    heap_locals(state, new_locals);
    isolated(1);
  }
 Object* VariableScope::get_local_internal(STATE, int pos) {
    if(isolated()) {
      return heap_locals()->at(pos);
    } else {
      return get_local(pos);
    }
  }
 void VariableScope::set_local_internal(STATE, int pos, Object* val) {
    if(isolated()) {
      heap_locals()->put(state, pos, val);
    } else {
      set_local(pos, val);
    }
  }
Exemple #4
0
bool Graph::isolated(std::shared_ptr<BBlock> leaf,
                            vector_shared<BBlock> finished_blocks) {
    if(leaf == nullptr) leaf = root;

    if(std::find(finished_blocks.begin(), finished_blocks.end(), leaf)
        != finished_blocks.end()) {
        return true;
    }
    finished_blocks.push_back(leaf);

    bool correct = dominator_check(leaf, root);

    if(!correct) {
        std::cout << std::hex << leaf->get_loc() << std::endl;
        return false;
    }

    if(leaf->jmp.use_count()  != 0)  correct = correct && isolated(leaf->jmp.lock(),  finished_blocks);
    if(leaf->fall.use_count() != 0) correct = correct && isolated(leaf->fall.lock(), finished_blocks);

    return correct;
}
Exemple #5
0
int main(int argc, const char * argv[]) {
    ifstream fstream("input.txt");
    ofstream edges("edges.txt");
    ofstream coords("coords.txt");
    ofstream obs("obs.txt");
    ofstream json("fca.json");
    vector<string> input;
    string line;
    if (fstream.is_open()) {
        while (getline(fstream, line)) {
            input.push_back(line);
        }
        fstream.close();
        int num_obs = (int)input.size();
        unordered_set<bitset<MAX> > concepts;
        vector<BitObj*> extents;
        findConc(input, concepts, extents);
        vector<bitset<MAX> > relation(concepts.size());
        nodeJSON(extents, json);
        findEdges(extents, relation, edges);
        linkJSON(json);
        findCoords(extents, coords);
        nodeObs(extents, obs, num_obs);
        
        //Set operations
        ifstream com("com.txt");
        cout << "Computing operations...\n";
        string line;
        while (getline(com, line)) {
            cout << '\n';
            bitset<MAX> A = convInput(line.substr(2), num_obs);
            cout << "Input A: ";
            printObj(A, cout, num_obs);
            switch (line[0]) {
                case 'c':
                    cout << "Closure of A: ";
                    printObj(closure(extents, A).second, cout, num_obs);
                    break;
                case 'b':
                    cout << "Boundary of A: ";
                    printObj(boundary(extents, A, num_obs).second, cout, num_obs);
                    break;
                case 'i':
                    cout << "Interior of A: ";
                    printObj(interior(extents, A, num_obs), cout, num_obs);
                    break;
                case 'd':
                    cout << "Derived set of A: ";
                    printObj(derived(extents, A, num_obs), cout, num_obs);
                    break;
                case 's':
                    cout << "Isolated point of A: ";
                    printObj(isolated(extents, A, num_obs), cout, num_obs);
                    break;
            }
        }
        for (BitObj *b : extents)
            delete b;
    }
    else
        cerr << "Unable to open file" << endl;
    return 0;
}
//_________________________________________________________________________
bool graph_molloy_hash::isolated(int v, int K, int *Kbuff, bool *visited) {
  if(K<2) return false;
#ifdef OPT_ISOLATED
  if(K<=deg[v]+1) return false;
#endif //OPT_ISOLATED
  int *seen  = Kbuff;
  int *known = Kbuff;
  int *max   = Kbuff + K;
  *(known++) = v;
  visited[v] = true;
  bool is_isolated = true;
  
  while(known != seen) {
    v = *(seen++);
    int *ww = neigh[v];
    int w;
    for(int d=HASH_SIZE(deg[v]); d--; ww++) if((w=*ww)!=HASH_NONE && !visited[w]) {
#ifdef OPT_ISOLATED
      if(K<=deg[w]+1 || known == max) {
#else //OPT_ISOLATED
      if(known == max) {
#endif //OPT_ISOLATED
        is_isolated = false;
        goto end_isolated;
      }
      visited[w] = true;
      *(known++) = w;
    }
  }
end_isolated:
  // Undo the changes to visited[]...
  while(known != Kbuff) visited[*(--known)] = false;
  return is_isolated;
}

//_________________________________________________________________________
int graph_molloy_hash::random_edge_swap(int K, int *Kbuff, bool *visited) {
  // Pick two random vertices a and c
  int f1 = pick_random_vertex();
  int f2 = pick_random_vertex();
  // Check that f1 != f2
  if(f1==f2) return 0;
  // Get two random edges (f1,*f1t1) and (f2,*f2t2)
  int *f1t1 = random_neighbour(f1);
  int t1 = *f1t1;
  int *f2t2 = random_neighbour(f2);
  int t2 = *f2t2;
  // Check simplicity
  if(t1==t2 || f1==t2 || f2==t1) return 0;
  if(is_edge(f1,t2) || is_edge(f2,t1)) return 0;
  // Swap
  int *f1t2 = H_rpl(neigh[f1],deg[f1],f1t1,t2);
  int *f2t1 = H_rpl(neigh[f2],deg[f2],f2t2,t1);
  int *t1f2 = H_rpl(neigh[t1],deg[t1],f1,f2);
  int *t2f1 = H_rpl(neigh[t2],deg[t2],f2,f1);
  // isolation test
  if(K<=2) return 1;
  if( !isolated(f1, K, Kbuff, visited) && !isolated(f2, K, Kbuff, visited) )
    return 1;
  // undo swap
  H_rpl(neigh[f1],deg[f1],f1t2,t1);
  H_rpl(neigh[f2],deg[f2],f2t1,t2);
  H_rpl(neigh[t1],deg[t1],t1f2,f1);
  H_rpl(neigh[t2],deg[t2],t2f1,f2);
  return 0;
}