-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathParamDef.cs
More file actions
106 lines (81 loc) · 3.23 KB
/
Copy pathParamDef.cs
File metadata and controls
106 lines (81 loc) · 3.23 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Mono.ILASM.ParamDef
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2003 Jackson Harper, All rights reserved
//
using System;
using System.Collections;
namespace Mono.ILASM {
/// <summary>
/// Definition of a parameter passed to a method
/// </summary>
public class ParamDef : ICustomAttrTarget {
private PEAPI.ParamAttr attr;
private string name;
private BaseTypeRef typeref;
private bool is_defined;
private PEAPI.Param peapi_param;
private PEAPI.Constant defval;
private ArrayList customattr_list;
private PEAPI.NativeType native_type;
public static readonly ParamDef Ellipsis = new ParamDef (new PEAPI.ParamAttr (), "ELLIPSIS", null);
public ParamDef (PEAPI.ParamAttr attr, string name,
BaseTypeRef typeref) {
this.attr = attr;
this.name = name;
this.typeref = typeref;
is_defined = false;
defval = null;
}
public void AddDefaultValue (PEAPI.Constant cVal)
{
defval = cVal;
}
public void AddCustomAttribute (CustomAttr customattr)
{
if (customattr_list == null)
customattr_list = new ArrayList ();
customattr_list.Add (customattr);
}
public void AddMarshalInfo (PEAPI.NativeType native_type)
{
this.native_type = native_type;
}
public BaseTypeRef Type {
get { return typeref; }
}
public string TypeName {
get { return typeref.FullName; }
}
public string Name {
get { return name; }
}
public PEAPI.Param PeapiParam {
get { return peapi_param; }
}
public bool IsSentinel ()
{
return (typeref is SentinelTypeRef && this != Ellipsis);
}
public void Define (CodeGen code_gen)
{
if (is_defined)
return;
typeref.Resolve (code_gen);
peapi_param = new PEAPI.Param (attr,
name, typeref.PeapiType);
if (defval != null) {
peapi_param.AddDefaultValue (defval);
}
if (customattr_list != null)
foreach (CustomAttr customattr in customattr_list)
customattr.AddTo (code_gen, peapi_param);
if (native_type != null)
peapi_param.AddMarshallInfo (native_type);
is_defined = true;
}
}
}