completelattice.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 47 行
SCALA
47 行
/* NSC -- new Scala compiler * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */// $Id: CompleteLattice.scala 14416 2008-03-19 01:17:25Z mihaylov $package scala.tools.nsc.backend.icode.analysis/** A complete lattice. */trait CompleteLattice { type Elem <: AnyRef /** Hold together local variable and stack state. The * equals method uses reference equality for top and bottom, * and structural equality for other values. */ case class IState[V, S](val vars: V, val stack: S) { override def equals(other: Any): Boolean = other match { case that: IState[_, _] => if ((this eq bottom) || (that eq bottom)) this eq that else if ((this eq top) || (that eq top)) this eq that else (stack == that.stack && vars == that.vars) case _ => false } } /** Return the least upper bound of <code>a</code> and <code>b</code> */ def lub2(a: Elem, b: Elem): Elem /** Return the top element. */ def top: Elem /** Return the bottom element. */ def bottom: Elem /** Compute the least upper bound of a list of elements. */ def lub(xs: List[Elem]): Elem = try { if (xs == Nil) bottom else xs reduceLeft lub2 } catch { case e: LubError => Console.println("Lub on blocks: " + xs) throw e }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?