Files
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
docs
errors
ilasm
codegen
Assembly.cs
BaseClassRef.cs
BaseGenericTypeRef.cs
BaseMethodRef.cs
BaseTypeRef.cs
BranchInstr.cs
CalliInstr.cs
CatchBlock.cs
CodeGen.cs
CustomAttr.cs
DataDef.cs
DebuggingInfo.cs
DeclSecurity.cs
EmitByteInstr.cs
EventDef.cs
ExternFieldRef.cs
ExternMethodRef.cs
ExternTable.cs
ExternTypeRef.cs
FaultBlock.cs
FeatureAttr.cs
FieldDef.cs
FieldInstr.cs
FieldRef.cs
FileRef.cs
FilterBlock.cs
FinallyBlock.cs
GenericArguments.cs
GenericMethodRef.cs
GenericMethodSig.cs
GenericParamRef.cs
GenericParameters.cs
GenericTypeInst.cs
GlobalFieldRef.cs
GlobalMethodRef.cs
HandlerBlock.cs
IFieldRef.cs
IInstr.cs
ISehClause.cs
InstrTable.cs
IntInstr.cs
LabelInfo.cs
LdcInstr.cs
LdstrInstr.cs
LdtokenInstr.cs
Local.cs
MethodDef.cs
MethodInstr.cs
MethodPointerTypeRef.cs
MethodRef.cs
MiscInstr.cs
ModifiableType.cs
Module.cs
ParamDef.cs
PeapiTypeRef.cs
Permission.cs
PermissionMember.cs
PermissionSet.cs
PrimitiveTypeRef.cs
PropertyDef.cs
Sentinel.cs
SimpInstr.cs
SwitchInstr.cs
TryBlock.cs
TypeDef.cs
TypeInstr.cs
TypeManager.cs
TypeRef.cs
TypeSpecFieldRef.cs
TypeSpecMethodRef.cs
parser
scanner
tests
AssemblyInfo.cs
Driver.cs
Makefile
Report.cs
ilasm.exe.sources
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/mcs/ilasm/codegen/ExternMethodRef.cs

126 lines
4.8 KiB
C#
Raw Normal View History

//
// Mono.ILASM.ExternMethodRef
//
// Author(s):
// Jackson Harper (Jackson@LatitudeGeo.com)
//
// (C) 2003 Jackson Harper, All rights reserved
//
using System;
using System.Collections;
namespace Mono.ILASM {
public class ExternMethodRef : BaseMethodRef {
public ExternMethodRef (ExternTypeRef owner, BaseTypeRef ret_type,
PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
: base (owner, call_conv, ret_type, name, param, gen_param_count)
{
}
public override void Resolve (CodeGen code_gen)
{
if (is_resolved)
return;
if ((call_conv & PEAPI.CallConv.Vararg) != 0) {
ResolveVararg (code_gen);
return;
}
PEAPI.Type[] param_list = new PEAPI.Type[param.Length];
string write_name;
ret_type.Resolve (code_gen);
int count = 0;
foreach (BaseTypeRef typeref in param) {
typeref.Resolve (code_gen);
param_list[count++] = typeref.PeapiType;
}
if (name == "<init>")
write_name = ".ctor";
else
write_name = name;
owner.Resolve (code_gen);
if (owner.UseTypeSpec) {
PEAPI.Type owner_ref = owner.PeapiType;
peapi_method = code_gen.PEFile.AddMethodToTypeSpec (owner_ref, write_name,
ret_type.PeapiType, param_list, gen_param_count);
} else {
PEAPI.ClassRef owner_ref;
owner_ref = (PEAPI.ClassRef) owner.PeapiType;
peapi_method = owner_ref.AddMethod (write_name,
ret_type.PeapiType, param_list, gen_param_count);
}
peapi_method.AddCallConv (call_conv);
is_resolved = true;
}
protected void ResolveVararg (CodeGen code_gen)
{
if (is_resolved)
return;
ArrayList param_list = new ArrayList ();
ArrayList opt_list = new ArrayList ();
bool in_opt = false;
string write_name;
ret_type.Resolve (code_gen);
foreach (BaseTypeRef typeref in param) {
if (in_opt) {
typeref.Resolve (code_gen);
opt_list.Add (typeref.PeapiType);
} else if (typeref is SentinelTypeRef) {
in_opt = true;
} else {
typeref.Resolve (code_gen);
param_list.Add (typeref.PeapiType);
}
}
if (name == "<init>")
write_name = ".ctor";
else
write_name = name;
if (owner.IsArray)
Report.Error ("Vararg methods on arrays are not supported yet.");
owner.Resolve (code_gen);
if (owner.UseTypeSpec) {
PEAPI.Type owner_ref = owner.PeapiType;
peapi_method = code_gen.PEFile.AddVarArgMethodToTypeSpec (owner_ref,
write_name, ret_type.PeapiType,
(PEAPI.Type[]) param_list.ToArray (typeof (PEAPI.Type)),
(PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
} else {
PEAPI.ClassRef owner_ref;
owner_ref = (PEAPI.ClassRef) owner.PeapiType;
peapi_method = owner_ref.AddVarArgMethod (write_name,
ret_type.PeapiType,
(PEAPI.Type[]) param_list.ToArray (typeof (PEAPI.Type)),
(PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
}
peapi_method.AddCallConv (call_conv);
is_resolved = true;
}
}
}