summaryrefslogtreecommitdiff
path: root/sources/scalac/symtab/classfile/SymblParser.java
blob: d540b698d5f719bf101962dd2e33847a42952417 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
**                                                                      **
** $Id$
\*                                                                      */

package scalac.symtab.classfile;

import scalac.*;
import scalac.symtab.*;
import scalac.util.*;
import java.io.*;


public class SymblParser extends ClassParser {

    /** the global compilation environment
     */

    public SymblParser(Global global) {
	super(global);
    }
    /** complete class symbol c by loading the class
     */
    public void complete(Symbol c) {
        Phase phase = global.currentPhase;
        global.currentPhase = global.getFirstPhase();
	//System.out.println("loading " + c);//DEBUG
	try {
	    long msec = System.currentTimeMillis();
	    String filename = SourceRepresentation.externalizeFileName(
		c.fullName()) + ".symbl";
	    AbstractFile f = global.classPath.openFile(filename);
	    if (f == null)
		global.error("could not read class " + c);
	    else {
		byte[] data = f.read();
		new UnPickle(c, data, Name.fromString(filename));
		global.operation("loaded " + f.getPath() + " in " +
				 (System.currentTimeMillis() - msec) + "ms");
		/*
		  if (!global.separate)
		    new SourceCompleter(global).complete(c);//for now
		*/
	    }
	} catch (IOException e) {
	    if (global.debug) e.printStackTrace();
	    global.error("i/o error while loading " + c);
	    c.setInfo(Type.ErrorType);
        }
        global.currentPhase = phase;
    }
}