summaryrefslogtreecommitdiff
path: root/src/msil/ch/epfl/lamp/compiler/msil/emit/FieldBuilder.scala
blob: 3ea06382e5a74793e21b09c9a9acf25edc1cc818 (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
57
/*
 * System.Reflection.Emit-like API for writing .NET assemblies to MSIL
 */


package ch.epfl.lamp.compiler.msil.emit

import ch.epfl.lamp.compiler.msil.FieldInfo
import ch.epfl.lamp.compiler.msil.Type
import ch.epfl.lamp.compiler.msil.FieldAttributes
import ch.epfl.lamp.compiler.msil.ConstructorInfo
import java.io.IOException

/**
 * Discovers the attributes of a field and provides access to field metadata.
 *
 * @author Nikolay Mihaylov
 * @version 1.0
 */
class FieldBuilder(name: String, declType: Type, attrs: Int, fieldType: Type)
      extends FieldInfo(name, declType, attrs, fieldType)
      with ICustomAttributeSetter
      with Visitable
{

    //##########################################################################
    // public interface

    /** Sets a custom attribute. */
    def SetCustomAttribute(constr: ConstructorInfo, value: Array[Byte]) {
	addCustomAttribute(constr, value)
    }

    //##########################################################################

    /** the apply method for a visitor */
    @throws(classOf[IOException])
    def apply(v: Visitor) {
	v.caseFieldBuilder(this)
    }

    //##########################################################################

    protected var defaultValue: Object = _

    /** Sets the default value of this field. */
    def SetConstant(defaultValue: Object) {
        this.defaultValue = defaultValue
    }

    /** Specifies the field layout. */
    def SetOffset(iOffset: Int) {
	//this.fieldOffset = FieldAttributes.Offset.Value(iOffset)
    }

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