mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Can make a fresh copy by calling Instantiate(null)
This commit is contained in:
parent
d35c8c196b
commit
b75004cd20
@ -58,7 +58,7 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
|
|
||||||
public static string SubstituteInType(String type, Dictionary<string,TypeRepTemplate> argMap)
|
public static string SubstituteInType(String type, Dictionary<string,TypeRepTemplate> argMap)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(type))
|
if (String.IsNullOrEmpty(type) || argMap == null)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
TypeVarMapper mapper = new TypeVarMapper(argMap);
|
TypeVarMapper mapper = new TypeVarMapper(argMap);
|
||||||
@ -2139,6 +2139,7 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
Variant = copyFrom.Variant;
|
Variant = copyFrom.Variant;
|
||||||
BoxedJava = copyFrom.BoxedJava;
|
BoxedJava = copyFrom.BoxedJava;
|
||||||
HasBoxedRep = copyFrom.HasBoxedRep;
|
HasBoxedRep = copyFrom.HasBoxedRep;
|
||||||
|
Tree = copyFrom.Tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TypeRepTemplate(string tName, string[] tParams, string[] usePath, AliasRepTemplate[] aliases, string[] imports, string javaTemplate)
|
protected TypeRepTemplate(string tName, string[] tParams, string[] usePath, AliasRepTemplate[] aliases, string[] imports, string javaTemplate)
|
||||||
@ -2214,10 +2215,12 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
Inherits[i] = TemplateUtilities.SubstituteInType(Inherits[i],args);
|
Inherits[i] = TemplateUtilities.SubstituteInType(Inherits[i],args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InstantiatedTypes = new TypeRepTemplate[args.Count];
|
InstantiatedTypes = new TypeRepTemplate[InstantiatedTypes.Length];
|
||||||
for (int i = 0; i < TypeParams.Length; i++)
|
if (args != null) {
|
||||||
{
|
for (int i = 0; i < TypeParams.Length; i++)
|
||||||
InstantiatedTypes[i] = args[TypeParams[i]];
|
{
|
||||||
|
InstantiatedTypes[i] = args[TypeParams[i]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BoxedJava = TemplateUtilities.SubstituteInType(BoxedJava,args);
|
BoxedJava = TemplateUtilities.SubstituteInType(BoxedJava,args);
|
||||||
base.Apply(args);
|
base.Apply(args);
|
||||||
@ -2874,7 +2877,9 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
||||||
{
|
{
|
||||||
EnumRepTemplate copy = new EnumRepTemplate(this);
|
EnumRepTemplate copy = new EnumRepTemplate(this);
|
||||||
copy.Apply(mkTypeMap(args));
|
if (args != null && args.Count != 0) {
|
||||||
|
copy.Apply(mkTypeMap(args));
|
||||||
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
#region Equality
|
#region Equality
|
||||||
@ -2955,6 +2960,19 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ResolveResult Resolve(String name, IList<TypeRepTemplate> args, DirectoryHT<TypeRepTemplate> AppEnv)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ("Invoke" == name && matchParamsToArgs(Invoke.Params, Invoke.ParamArray, args, AppEnv))
|
||||||
|
{
|
||||||
|
ResolveResult res = new ResolveResult();
|
||||||
|
res.Result = Invoke;
|
||||||
|
res.ResultType = BuildType(Invoke.Return, AppEnv);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return base.Resolve(name, args, AppEnv);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Apply(Dictionary<string,TypeRepTemplate> args)
|
public override void Apply(Dictionary<string,TypeRepTemplate> args)
|
||||||
{
|
{
|
||||||
Invoke.Apply(args);
|
Invoke.Apply(args);
|
||||||
@ -2963,7 +2981,9 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
||||||
{
|
{
|
||||||
DelegateRepTemplate copy = new DelegateRepTemplate(this);
|
DelegateRepTemplate copy = new DelegateRepTemplate(this);
|
||||||
copy.Apply(mkTypeMap(args));
|
if (args != null && args.Count != 0) {
|
||||||
|
copy.Apply(mkTypeMap(args));
|
||||||
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3333,7 +3353,9 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
||||||
{
|
{
|
||||||
InterfaceRepTemplate copy = new InterfaceRepTemplate(this);
|
InterfaceRepTemplate copy = new InterfaceRepTemplate(this);
|
||||||
copy.Apply(mkTypeMap(args));
|
if (args != null && args.Count != 0) {
|
||||||
|
copy.Apply(mkTypeMap(args));
|
||||||
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3645,7 +3667,9 @@ namespace Twiglet.CS2J.Translator.TypeRep
|
|||||||
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
public override TypeRepTemplate Instantiate(ICollection<TypeRepTemplate> args)
|
||||||
{
|
{
|
||||||
ClassRepTemplate copy = new ClassRepTemplate(this);
|
ClassRepTemplate copy = new ClassRepTemplate(this);
|
||||||
copy.Apply(copy.mkTypeMap(args));
|
if (args != null && args.Count != 0) {
|
||||||
|
copy.Apply(mkTypeMap(args));
|
||||||
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user