To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Bundle.scala 1.53 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1
2
package uvm

Kunshan Wang's avatar
Kunshan Wang committed
3
import uvm.types._
Kunshan Wang's avatar
Kunshan Wang committed
4
import uvm.ssavariables._
Kunshan Wang's avatar
Kunshan Wang committed
5

Kunshan Wang's avatar
Kunshan Wang committed
6
class Bundle {
Kunshan Wang's avatar
Kunshan Wang committed
7
8
9
10
11
12
13
14
15
16
  /**
   * Namespace of all SSA variables, global or local.
   */
  val varNs = new SimpleNamespace[SSAVariable]()

  /**
   * All global SSA varaibles.
   */
  val globalVarNs = new SimpleNamespace[GlobalVariable]()

Kunshan Wang's avatar
Kunshan Wang committed
17
18
  val typeNs = new SimpleNamespace[Type]()
  val funcSigNs = new SimpleNamespace[FuncSig]()
Kunshan Wang's avatar
Kunshan Wang committed
19
20
  val constantNs = new SimpleNamespace[Constant]()
  val globalCellNs = new SimpleNamespace[GlobalCell]()
Kunshan Wang's avatar
Kunshan Wang committed
21
  val funcNs = new SimpleNamespace[Function]()
Kunshan Wang's avatar
Kunshan Wang committed
22

Kunshan Wang's avatar
Kunshan Wang committed
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

  private def simpleMerge[T <: Identified](oldNs: Namespace[T], newNs: Namespace[T]) {
    for (cand <- newNs.all) {
      try {
        oldNs.add(cand)
      } catch {
        case e: NameConflictException =>
          throw new IllegalRedefinitionException(
            "Redefinition of type, function signature, declared constant," +
              " global data or global value is not allowed", e);
      }
    }
  }
  
  private def mergeFunc(oldNs: Namespace[Function], newNs: Namespace[Function]) {
    for (cand <- newNs.all) {
      val id = cand.id
      oldNs.get(id) match {
        case None => oldNs.add(cand)
        case Some(oldObj) => oldObj.cfg = cand.cfg
      }
    }
  }
  def merge(newBundle: Bundle) {
    simpleMerge(typeNs, newBundle.typeNs)
    simpleMerge(funcSigNs, newBundle.funcSigNs)
    simpleMerge(declConstNs, newBundle.declConstNs)
    simpleMerge(globalDataNs, newBundle.globalDataNs)
    simpleMerge(globalValueNs, newBundle.globalValueNs)
    mergeFunc(funcNs, newBundle.funcNs)
  }
Kunshan Wang's avatar
Kunshan Wang committed
54
}