public virtual BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { BaseMethodRef mr = null; /* Note: FullName not reqd as this is cached per object */ string key = MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, true); if (method_table == null) { method_table = new Hashtable(); } else { mr = (BaseMethodRef)method_table [key]; } if (mr == null) { mr = CreateMethodRef(ret_type, call_conv, name, param, gen_param_count); method_table [key] = mr; } return(mr); }
public CalliInstr (PEAPI.CallConv call_conv, BaseTypeRef ret_type, BaseTypeRef[] param, Location loc) : base (loc) { this.call_conv = call_conv; this.ret_type = ret_type; this.param = param; }
public CalliInstr(PEAPI.CallConv call_conv, BaseTypeRef ret_type, BaseTypeRef[] param, Location loc) : base(loc) { this.call_conv = call_conv; this.ret_type = ret_type; this.param = param; }
private PEAPI.Method ResolveAsMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen) { ExternTypeRef type_ref = code_gen.ThisModule.GetTypeRef(FullName, false); ExternMethodRef methodref = (ExternMethodRef)type_ref.GetMethodRef(ret_type, call_conv, name, param, gen_param_count); methodref.Resolve(code_gen); return(methodref.PeapiMethod); }
public MethodPointerTypeRef(PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list, ArrayList conv_list, string sig_mod) : base(String.Empty, conv_list, sig_mod) { this.callconv = callconv; this.ret = ret; this.param_list = param_list; // We just need these to not break the interface full_name = BuildTypeName(); //sig_mod = String.Empty; }
public MethodPointerTypeRef (PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list, ArrayList conv_list, string sig_mod) : base (String.Empty, conv_list, sig_mod) { this.callconv = callconv; this.ret = ret; this.param_list = param_list; // We just need these to not break the interface full_name = BuildTypeName (); //sig_mod = String.Empty; }
protected override BaseMethodRef CreateMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { if (SigMod == null | SigMod == "") { return(new MethodRef(this, call_conv, ret_type, name, param, gen_param_count)); } else { return(new TypeSpecMethodRef(this, call_conv, ret_type, name, param, gen_param_count)); } }
// @include_optional: include optional parameters for vararg methods // This will be true mostly for *Ref use, eg. methodrefs at call sites // and false for *Def (include only the required params) public static string CreateSignature(BaseTypeRef RetType, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional) { 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)); } }
public PEAPI.Method ResolveMethod(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen) { string signature = MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, false); MethodDef methoddef = (MethodDef)method_table[signature]; if (methoddef != null) { return(methoddef.Resolve(code_gen, classdef)); } return(ResolveAsMethodRef(ret_type, call_conv, name, param, gen_param_count, code_gen)); }
private void FixAttributes() { if (name == ".ctor" || name == ".cctor") { meth_attr |= PEAPI.MethAttr.SpecialName | PEAPI.MethAttr.RTSpecialName; } // If methods aren't flagged as static they are instance if ((PEAPI.MethAttr.Static & meth_attr) == 0) { call_conv |= PEAPI.CallConv.Instance; } }
public BaseMethodRef (BaseTypeRef owner, PEAPI.CallConv call_conv, BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count) { this.owner = owner; this.call_conv = call_conv; this.ret_type = ret_type; this.name = name; this.param = param; this.gen_param_count = gen_param_count; if (gen_param_count > 0) CallConv |= PEAPI.CallConv.Generic; is_resolved = false; }
public BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { string key = type_ref.FullName + MethodDef.CreateSignature(ret_type, name, param, gen_param_count) + type_ref.SigMod; TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef; if (mr == null) { mr = new TypeSpecMethodRef(this, ret_type, call_conv, name, param, gen_param_count); method_table [key] = mr; } return(mr); }
public override BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string meth_name, BaseTypeRef[] param, int gen_param_count) { /* Note: Using FullName here as we are caching in a static hashtable */ string key = FullName + MethodDef.CreateSignature(ret_type, call_conv, meth_name, param, gen_param_count, true); TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef; if (mr == null) { mr = new TypeSpecMethodRef(this, call_conv, ret_type, meth_name, param, gen_param_count); s_method_table [key] = mr; } return(mr); }
public BaseMethodRef(BaseTypeRef owner, PEAPI.CallConv call_conv, BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count) { this.owner = owner; this.call_conv = call_conv; this.ret_type = ret_type; this.name = name; this.param = param; this.gen_param_count = gen_param_count; if (gen_param_count > 0) { CallConv |= PEAPI.CallConv.Generic; } is_resolved = false; }
public PEAPI.Method ResolveVarargMethod(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef [] param, int gen_param_count, PEAPI.Type [] opt, CodeGen code_gen) { // Only MethodDef sig required to lookup in the method_table string signature = MethodDef.CreateSignature(ret_type, call_conv, name, param, 0, false); MethodDef methoddef = (MethodDef)method_table[signature]; if (methoddef != null) { methoddef.Resolve(code_gen, classdef); return(methoddef.GetVarargSig( opt, MethodDef.CreateSignature(ret_type, call_conv, name, param, 0, true))); } return(ResolveAsMethodRef(ret_type, call_conv, name, param, gen_param_count, code_gen)); }
public override BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { /* Use FullName also here, as we are caching in a static hashtable */ string key = FullName + MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, true); TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef; if (mr != null) { return(mr); } //FIXME: generic methodref for primitive type? mr = new TypeSpecMethodRef(this, call_conv, ret_type, name, param, gen_param_count); s_method_table [key] = mr; return(mr); }
public MethodDef(CodeGen codegen, PEAPI.MethAttr meth_attr, PEAPI.CallConv call_conv, PEAPI.ImplAttr impl_attr, string name, BaseTypeRef ret_type, ArrayList param_list, Location start, GenericParameters gen_params, TypeDef type_def) { this.codegen = codegen; this.meth_attr = meth_attr; this.call_conv = call_conv; this.impl_attr = impl_attr; this.name = name; this.param_list = param_list; this.type_def = type_def; this.gen_params = gen_params; this.ret_param = new ParamDef(PEAPI.ParamAttr.Default, "", ret_type); this.start = (Location)start.Clone(); inst_list = new ArrayList(); label_table = new Hashtable(); labelref_table = new Hashtable(); label_list = new ArrayList(); local_list = new ArrayList(); named_local_tables = new ArrayList(); named_local_tables.Add(new Hashtable()); current_scope_depth = 0; entry_point = false; zero_init = false; init_locals = false; max_stack = -1; pinvoke_info = false; is_defined = false; is_resolved = false; ResolveGenParams(); CreateSignature(); codegen.BeginMethodDef(this); if (codegen.SymbolWriter != null) { source = codegen.SymbolWriter.BeginMethod(this, start); } }
public MethodDef (CodeGen codegen, PEAPI.MethAttr meth_attr, PEAPI.CallConv call_conv, PEAPI.ImplAttr impl_attr, string name, BaseTypeRef ret_type, ArrayList param_list, Location start, GenericParameters gen_params, TypeDef type_def) { this.codegen = codegen; this.meth_attr = meth_attr; this.call_conv = call_conv; this.impl_attr = impl_attr; this.name = name; this.param_list = param_list; this.type_def = type_def; this.gen_params = gen_params; this.ret_param = new ParamDef (PEAPI.ParamAttr.Default, "", ret_type); this.start = (Location) start.Clone (); inst_list = new ArrayList (); label_table = new Hashtable (); labelref_table = new Hashtable (); label_list = new ArrayList (); local_list = new ArrayList (); named_local_tables = new ArrayList (); named_local_tables.Add (new Hashtable ()); current_scope_depth = 0; entry_point = false; zero_init = false; init_locals = false; max_stack = -1; pinvoke_info = false; is_defined = false; is_resolved = false; ResolveGenParams (); CreateSignature (); codegen.BeginMethodDef (this); if (codegen.SymbolWriter != null) source = codegen.SymbolWriter.BeginMethod (this, start); }
protected override BaseMethodRef CreateMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { return(new ExternMethodRef(this, ret_type, call_conv, name, param, gen_param_count)); }
protected override BaseMethodRef CreateMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) { throw new InternalErrorException("Should not be called"); }
public TypeSpecMethodRef(BaseTypeRef owner, PEAPI.CallConv call_conv, BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count) : base(owner, call_conv, ret_type, name, param, gen_param_count) { }
private void FixAttributes () { if (name == ".ctor" || name == ".cctor") meth_attr |= PEAPI.MethAttr.SpecialName | PEAPI.MethAttr.RTSpecialName; // If methods aren't flagged as static they are instance if ((PEAPI.MethAttr.Static & meth_attr) == 0) call_conv |= PEAPI.CallConv.Instance; }
public MethodPointerTypeRef(PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list) : this(callconv, ret, param_list, null, String.Empty) { }
public GlobalMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count) : base(null, call_conv, ret_type, name, param, gen_param_count) { }
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); if (gen_param_count > 0) { builder.AppendFormat("`{0}", gen_param_count); } builder.Append('('); if (param_list != null) { bool first = true; foreach (BaseTypeRef param in param_list) { if (!first) { builder.Append(','); } builder.Append(param.FullName); first = false; if (!include_optional && param is SentinelTypeRef) { break; } } } builder.Append(')'); return(builder.ToString()); }
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) { }
protected abstract BaseMethodRef CreateMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count);