|
Scala example source code file (Symbol.scala)
The Scala Symbol.scala source codepackage scala.tools.scalap package scalax package rules package scalasig import ScalaSigEntryParsers._ trait Symbol extends Flags { def name : String def parent : Option[Symbol] def children : Seq[Symbol] def path : String = parent.map(_.path + ".").getOrElse("") + name } case object NoSymbol extends Symbol { def name = "<no symbol>" def parent = None def hasFlag(flag : Long) = false def children = Nil } abstract class ScalaSigSymbol extends Symbol { def applyRule[A](rule : EntryParser[A]) : A = expect(rule)(entry) def applyScalaSigRule[A](rule : ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(rule)(entry.scalaSig) def entry : ScalaSig#Entry def index = entry.index lazy val children : Seq[Symbol] = applyScalaSigRule(ScalaSigParsers.symbols) filter (_.parent == Some(this)) lazy val attributes : Seq[AttributeInfo] = applyScalaSigRule(ScalaSigParsers.attributes) filter (_.symbol == this) } case class ExternalSymbol(name : String, parent : Option[Symbol], entry : ScalaSig#Entry) extends ScalaSigSymbol { override def toString = path def hasFlag(flag : Long) = false } case class SymbolInfo(name : String, owner : Symbol, flags : Int, privateWithin : Option[AnyRef], info : Int, entry : ScalaSig#Entry) { def symbolString(any : AnyRef) = any match { case sym : SymbolInfoSymbol => sym.index.toString case other => other.toString } override def toString = name + ", owner=" + symbolString(owner) + ", flags=" + flags.toHexString + ", info=" + info + (privateWithin match { case Some(any) => ", privateWithin=" + symbolString(any) case None => " " }) } abstract class SymbolInfoSymbol extends ScalaSigSymbol { def symbolInfo : SymbolInfo def entry = symbolInfo.entry def name = symbolInfo.name def parent = Some(symbolInfo.owner) def hasFlag(flag : Long) = (symbolInfo.flags & flag) != 0L lazy val infoType = applyRule(parseEntry(typeEntry)(symbolInfo.info)) } case class TypeSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol{ override def path = name } case class AliasSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol{ override def path = name } case class ClassSymbol(symbolInfo : SymbolInfo, thisTypeRef : Option[Int]) extends SymbolInfoSymbol { lazy val selfType = thisTypeRef.map{(x: Int) => applyRule(parseEntry(typeEntry)(x))} } case class ObjectSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol case class MethodSymbol(symbolInfo : SymbolInfo, aliasRef : Option[Int]) extends SymbolInfoSymbol Other Scala examples (source code examples)Here is a short list of links related to this Scala Symbol.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.