Blame view

build3/apps/shared/function_store.cpp 1.49 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  #include "function_store.h"
  #include <assert.h>
  
  namespace Shared {
  
  FunctionStore::FunctionStore() :
    m_numberOfFunctions(0)
  {
  }
  
  Function * FunctionStore::activeFunctionAtIndex(int i) {
    assert(i>=0 && i<m_numberOfFunctions);
    int index = 0;
    for (int k = 0; k < m_numberOfFunctions; k++) {
      Function * function = functionAtIndex(k);
      if (function->isActive() && function->isDefined()) {
        if (i == index) {
          return function;
        }
        index++;
      }
    }
    assert(false);
    return nullptr;
  }
  
  Function * FunctionStore::definedFunctionAtIndex(int i) {
    assert(i>=0 && i<m_numberOfFunctions);
    int index = 0;
    for (int k = 0; k < m_numberOfFunctions; k++) {
      if (functionAtIndex(k)->isDefined()) {
        if (i == index) {
          return functionAtIndex(k);
        }
        index++;
      }
    }
    assert(false);
    return nullptr;
  }
  
  int FunctionStore::numberOfFunctions() {
    return m_numberOfFunctions;
  }
  
  int FunctionStore::numberOfActiveFunctions() {
    int result = 0;
    for (int i = 0; i < m_numberOfFunctions; i++) {
      Function * function = functionAtIndex(i);
      if (function->isDefined() && function->isActive()) {
        result++;
      }
    }
    return result;
  }
  
  int FunctionStore::numberOfDefinedFunctions() {
    int result = 0;
    for (int i = 0; i < m_numberOfFunctions; i++) {
      if (functionAtIndex(i)->isDefined()) {
        result++;
      }
    }
    return result;
  }
  
  void FunctionStore::tidy() {
    for (int i = 0; i < m_numberOfFunctions; i++) {
      functionAtIndex(i)->tidy();
    }
  }
  
  }