summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer/MakeBoxingExplicitPhase.java
blob: e4d6f956b12a53419a4b11ecdfdd812cceca229e (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
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package scalac.transformer;

import scalac.Global;
import scalac.Phase;
import scalac.PhaseDescriptor;
import scalac.CompilationUnit;
import scalac.checkers.TreeChecker;
import scalac.symtab.Definitions;

/**
 * This phase makes boxing and unboxing of primitive values and arrays
 * explicit.
 */
public class MakeBoxingExplicitPhase extends Phase {

    //########################################################################
    // Private Fields

    private final Definitions definitions;
    private final TreeChecker checker;

    //########################################################################
    // Public Constructors

    /** Initializes this instance. */
    public MakeBoxingExplicitPhase(Global global, PhaseDescriptor descriptor) {
        super(global, descriptor);
        this.definitions = global.definitions;
        this.checker = new TreeChecker(definitions);
    }

    //########################################################################
    // Public Methods

    /** Applies this phase to the given compilation units. */
    public void apply(CompilationUnit[] units) {
        for (int i = 0; i < units.length; i++) {
            assert checker.check(units[i]);
            new scalac.atree.ATreeFromSTree(global.definitions)
                .translate(units[i]); // !!!
        }
    }

    //########################################################################
}