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

Bundle.scala 1.38 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
7
8
9
class Bundle {
  val typeNs = new SimpleNamespace[Type]()
  val funcSigNs = new SimpleNamespace[FuncSig]()
  val declConstNs = new SimpleNamespace[DeclaredConstant]()
Kunshan Wang's avatar
Kunshan Wang committed
10
  val globalDataNs = new SimpleNamespace[GlobalData]()
Kunshan Wang's avatar
Kunshan Wang committed
11
  val funcNs = new SimpleNamespace[Function]()
Kunshan Wang's avatar
Kunshan Wang committed
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
  val globalValueNs = new SimpleNamespace[GlobalValue]()

  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
44
}