Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -20,18 +20,17 @@ namespace Mono.ILASM {
public class CustomAttr {
private BaseMethodRef method_ref;
private byte[] data;
public CustomAttr (BaseMethodRef method_ref, byte[] data)
PEAPI.Constant constant;
public CustomAttr (BaseMethodRef method_ref, PEAPI.Constant constant)
{
this.method_ref = method_ref;
this.data = data;
this.method_ref = method_ref;
this.constant = constant;
}
public void AddTo (CodeGen code_gen, PEAPI.MetaDataElement elem)
{
method_ref.Resolve (code_gen);
code_gen.PEFile.AddCustomAttribute (method_ref.PeapiMethod, data, elem);
code_gen.PEFile.AddCustomAttribute (method_ref.PeapiMethod, constant, elem);
}
public bool IsSuppressUnmanaged (CodeGen codegen)

View File

@@ -707,13 +707,16 @@ namespace Mono.ILASM {
if (IsVararg)
signature = CreateVarargSignature (RetType, name, param_list);
else
signature = CreateSignature (RetType, name, param_list, GenParamCount);
signature = CreateSignature (RetType, name, param_list, GenParamCount, Attributes);
}
static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count)
static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count, PEAPI.MethAttr attrs)
{
StringBuilder builder = new StringBuilder ();
if ((attrs & PEAPI.MethAttr.Static) == 0)
builder.Append ("instance ");
builder.Append (RetType.FullName);
builder.Append (" ");
builder.Append (name);
@@ -777,10 +780,10 @@ namespace Mono.ILASM {
if ((call_conv & PEAPI.CallConv.Vararg) != 0)
return CreateVarargSignature (RetType, name, param_list, include_optional);
else
return CreateSignature (RetType, name, param_list, gen_param_count, include_optional);
return CreateSignature (RetType, name, param_list, gen_param_count, include_optional, call_conv);
}
static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list, bool include_optional)
static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list, bool include_optional)
{
StringBuilder builder = new StringBuilder ();
BaseTypeRef last = null;
@@ -815,10 +818,14 @@ namespace Mono.ILASM {
return builder.ToString ();
}
static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional, PEAPI.CallConv call_conv)
{
StringBuilder builder = new StringBuilder ();
if ((call_conv & PEAPI.CallConv.Instance) != 0)
builder.Append ("instance ");
builder.Append (RetType.FullName);
builder.Append (" ");
builder.Append (name);

View File

@@ -32,13 +32,6 @@ namespace Mono.ILASM {
if (owner_def == null)
Report.Error ("Reference to undefined class '" + owner.FullName + "'");
string write_name;
if (name == "<init>")
write_name = ".ctor";
else
write_name = name;
if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
peapi_method = owner_def.ResolveMethod (ret_type, call_conv, name,
param, gen_param_count, code_gen);

View File

@@ -104,7 +104,7 @@ namespace Mono.ILASM {
}
public void MakeCustomModified (CodeGen code_gen, PEAPI.CustomModifier modifier,
BaseClassRef klass)
BaseTypeRef klass)
{
use_type_spec = true;
conversion_list.Add (ConversionMethod.MakeCustomModified);
@@ -143,7 +143,7 @@ namespace Mono.ILASM {
break;
case ConversionMethod.MakeCustomModified:
peapi_type.MakeCustomModified (code_gen, (PEAPI.CustomModifier) conversion_list[++i],
(BaseClassRef) conversion_list[++i]);
(BaseTypeRef) conversion_list[++i]);
break;
}

View File

@@ -13,8 +13,8 @@ using System.Collections;
namespace Mono.ILASM {
public class Pair {
private PEAPI.Type type;
private string sig;
protected PEAPI.Type type;
protected string sig;
public Pair (PEAPI.Type type, string sig)
{
@@ -38,6 +38,31 @@ namespace Mono.ILASM {
}
}
class Triplet : Pair
{
string typeMod;
public Triplet (PEAPI.Type type, string sig, string typeMod)
: base (type, sig)
{
this.typeMod = typeMod;
}
public override int GetHashCode ()
{
return base.GetHashCode () ^ typeMod.GetHashCode ();
}
public override bool Equals (object o)
{
Triplet t = o as Triplet;
if (t == null)
return false;
return t.type == type && t.sig == sig && t.typeMod == typeMod;
}
}
public class PeapiTypeRef {
private PEAPI.Type peapi_type;
@@ -196,23 +221,34 @@ namespace Mono.ILASM {
}
public void MakeCustomModified (CodeGen code_gen, PEAPI.CustomModifier modifier,
BaseClassRef klass)
BaseTypeRef klass)
{
PEAPI.Type type;
use_type_spec = true;
Pair p = new Pair (peapi_type, modifier.ToString ());
Pair p = new Triplet (peapi_type, modifier.ToString (), klass.FullName);
type = type_table [p] as PEAPI.Type;
if (type == null) {
klass.Resolve (code_gen);
type = new PEAPI.CustomModifiedType (peapi_type,
modifier, klass.PeapiClass);
type = GetType (code_gen, modifier, klass);
type_table [p] = type;
}
peapi_type = type;
}
PEAPI.Type GetType (CodeGen code_gen, PEAPI.CustomModifier modifier, BaseTypeRef klass)
{
klass.Resolve (code_gen);
var bcr = klass as BaseClassRef;
if (bcr != null)
return new PEAPI.CustomModifiedType (peapi_type, modifier, bcr.PeapiClass);
var pt = klass as PrimitiveTypeRef;
return new PEAPI.CustomModifiedType (peapi_type, modifier, code_gen.PEFile.AddPrimitiveType ((PEAPI.PrimitiveType) pt.PeapiType));
throw new NotSupportedException (klass.GetType ().ToString ());
}
public void MakePinned ()
{
use_type_spec = true;

View File

@@ -354,7 +354,6 @@ namespace Mono.ILASM {
if (!IsValueType (name_space, name) && !IsEnumType (name_space, name) &&
is_value_class && (attr & PEAPI.TypeAttr.Sealed) == 0) {
Report.Warning (location, "Non-sealed value class, made sealed.");
attr |= PEAPI.TypeAttr.Sealed;
}
@@ -416,6 +415,10 @@ namespace Mono.ILASM {
{
ArrayList fielddef_list = new ArrayList ();
foreach (FieldDef fielddef in field_list) {
if (is_enum_class && fielddef.Name == "value__") {
fielddef.Attributes |= PEAPI.FieldAttr.SpecialName | PEAPI.FieldAttr.RTSpecialName;
}
fielddef.Define (code_gen, classdef);
fielddef_list.Add (fielddef.PeapiFieldDef);
}