summaryrefslogtreecommitdiff
path: root/sources/scala/tools/nsc/symtab/classfile/SymblfileParser.scala
blob: cb7e401b1c458f9f6cb2e4ff8348df8fbee684f3 (plain) (blame)
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
/* NSC -- new scala compiler
 * Copyright 2005 LAMP/EPFL
 * @author  Martin Odersky
 */
// $Id$
package scala.tools.nsc.symtab.classfile;

import scala.tools.util.{AbstractFile, AbstractFileReader};

import java.io.IOException;

abstract class SymblfileParser {

  val global: Global;
  import global._;

  private var current: AbstractFile = null;       // lock to detect recursive reads

  private object unpickler extends UnPickler {
    val global: SymblfileParser.this.global.type = SymblfileParser.this.global
  }

  def parse(file: AbstractFile, root: Symbol): unit = {
    assert(current == null, current);
    current = file;
    val in = new AbstractFileReader(file);
    if (root.isModule) unpickler.unpickle(in.buf, 0, root.linkedClass, root)
    else unpickler.unpickle(in.buf, 0, root, root.linkedModule);
    current = null
  }
}