public RoutineTemplateInstance(RoutineSymbol routine, IReadOnlyList<TypeSymbol> parameters, IReadOnlyList<TypeSymbol> tacitParameters)
     : base(RoutineType.Unknown, TokenType.Unknoun)
 {
     Routine = routine;
     Parameters = parameters;
     TacitParameters = tacitParameters;
 }
예제 #2
0
 public static RoutineSymbol MakeRoutineTemplateInstance(Root root, IReadOnlyList<GenericsInstance> inst, RoutineSymbol baseRoutine)
 {
     if (baseRoutine.Generics.Count > 0 || baseRoutine.TacitGeneric.Count > 0)
     {
         var prm = new List<TypeSymbol>();
         foreach (var v in baseRoutine.Generics)
         {
             var t = MakeClassTemplateInstance(root, inst, v);
             prm.Add(t);
         }
         var tprm = new List<TypeSymbol>();
         foreach (var v in baseRoutine.TacitGeneric)
         {
             var t = MakeClassTemplateInstance(root, inst, v);
             tprm.Add(t);
         }
         return root.RoutineManager.Issue(baseRoutine, prm, tprm);
     }
     else
     {
         return baseRoutine;
     }
 }
예제 #3
0
 public void Append(RoutineSymbol symbol)
 {
     ConvList.Add(symbol);
 }
예제 #4
0
 private RoutineSymbol ImportProperty(MethodInfo prop, string name)
 {
     var elem = new RoutineSymbol();
     if (ImportDictionary.ContainsKey(prop))
     {
         return (RoutineSymbol)ImportDictionary[prop];
     }
     ImportDictionary.Add(prop, elem);
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, prop);
     var generic = new List<GenericSymbol>();
     var arguments = CreateArgumentList(prop);
     var rt = ImportType(prop.ReturnType);
     elem.Initialize(name, RoutineType.Routine, TokenType.Unknoun, attribute, generic, arguments, rt);
     return elem;
 }
예제 #5
0
 private RoutineSymbol ImportConstructor(ConstructorInfo ctor)
 {
     var elem = new RoutineSymbol();
     if (ImportDictionary.ContainsKey(ctor))
     {
         return (RoutineSymbol)ImportDictionary[ctor];
     }
     ImportDictionary.Add(ctor, elem);
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, ctor);
     var generic = new List<GenericSymbol>();
     var arguments = CreateArgumentList(ctor);
     var rt = ImportType(ctor.DeclaringType);
     elem.Initialize(RoutineSymbol.ConstructorIdentifier, RoutineType.Routine, TokenType.Unknoun, attribute, generic, arguments, rt);
     return elem;
 }
예제 #6
0
 private RoutineSymbol ImportMethod(MethodInfo method)
 {
     var elem = new RoutineSymbol();
     if (ImportDictionary.ContainsKey(method))
     {
         return (RoutineSymbol)ImportDictionary[method];
     }
     ImportDictionary.Add(method, elem);
     var attribute = new List<AttributeSymbol>();
     AppendEmbededAttribute(attribute, method);
     var generic = CreateGenericList(method.GetGenericArguments());
     var arguments = CreateArgumentList(method);
     var rt = ImportType(method.ReturnType);
     elem.Initialize(method.Name, RoutineType.Routine, TokenType.Unknoun, attribute, generic, arguments, rt);
     return elem;
 }
예제 #7
0
 internal static OverLoadCallMatch MakeUnknown(RoutineSymbol call)
 {
     return new OverLoadCallMatch { Call = call, Result = CallMatchResult.Unknown };
 }
예제 #8
0
 internal static OverLoadCallMatch MakeNotCallable(RoutineSymbol call)
 {
     return new OverLoadCallMatch { Call = call, Result = CallMatchResult.NotCallable };
 }
예제 #9
0
 //todo さらに詳しい順位付けをする。
 //todo デフォルト引数に対応する。
 //todo 型制約に対応する。
 internal static OverLoadCallMatch MakeMatch(Root root, RoutineSymbol call, IReadOnlyList<GenericSymbol> fg, IReadOnlyList<ArgumentSymbol> fa,
     IReadOnlyList<GenericsInstance> inst, IReadOnlyList<TypeSymbol> ag, IReadOnlyList<TypeSymbol> aa)
 {
     var ig = new List<TypeSymbol>();
     var ia = new List<TypeSymbol>();
     var convs = new List<RoutineSymbol>();
     var result = new OverLoadCallMatch()
     {
         Call = call,
         FormalGenerics = fg,
         FormalArguments = fa,
         ScopeInstance = inst,
         ActualGenerics = ag,
         ActualArguments = aa,
         InstanceGenerics = ig,
         InstanceArguments = ia,
         Converters = convs,
     };
     if (TypeSymbol.HasAnyErrorType(fg) || TypeSymbol.HasAnyErrorType(fa.GetDataTypes()))
     {
         result.Result = CallMatchResult.Unknown;
         return result;
     }
     if (!OverLoadTypeMatch.ContainGenericCount(fg, ag))
     {
         result.Result = CallMatchResult.UnmatchGenericCount;
         return result;
     }
     if (!ContainArgumentCount(fa, aa) || !ContainTupleCount(fg, fa, ag, aa))
     {
         result.Result = CallMatchResult.UnmatchArgumentCount;
         return result;
     }
     InitInstance(fg, fa, ag, aa, ig, ia);
     var tgi = InferInstance(root, inst, ag, aa, ig, ia);
     if (TypeSymbol.HasAnyErrorType(tgi))
     {
         result.Result = CallMatchResult.UnmatchGenericType;
         return result;
     }
     for (int i = 0; i < ia.Count; i++)
     {
         var c = root.ConvManager.Find(aa[i], ia[i]);
         convs.Add(c);
     }
     result.Result = CheckConverterResult(convs);
     if (HasMatch(result.Result))
     {
         result.Call = GenericsInstance.MakeRoutineTemplateInstance(root, tgi, call);
     }
     return result;
 }
예제 #10
0
 public static bool HasLoadStoreCall(RoutineSymbol routine)
 {
     var rti = routine as RoutineTemplateInstance;
     if(rti != null)
     {
         return HasLoadStoreCall(rti.Routine);
     }
     return routine is PropertySymbol;
 }
예제 #11
0
 public void Append(RoutineSymbol symbol)
 {
     OpList[symbol.OperatorType].Add(symbol);
 }