Example #1
0
 private static function_node get_conversion(compiled_type_node in_type,compiled_type_node from,
     compiled_type_node to,string op_name, NetTypeScope scope)
 {
     //MethodInfo[] mia = in_type.compiled_type.GetMethods();
     List<MemberInfo> mia = GetMembers(in_type.compiled_type, op_name);
    
     foreach (MemberInfo mbi in mia)
     {
         if (!(mbi is MethodInfo))
             continue;
         MethodInfo mi = mbi as MethodInfo;
         if (mi.ReturnType != to.compiled_type)
         {
             continue;
         }
         ParameterInfo[] piarr = mi.GetParameters();
         if (piarr.Length != 1)
         {
             continue;
         }
         if (piarr[0].ParameterType != from.compiled_type)
         {
             continue;
         }
         return compiled_function_node.get_compiled_method(mi);
     }
     if (scope != null)
     {
         SymbolInfo si = scope.FindOnlyInType(op_name, scope);
         while (si != null)
         {
             if (si.sym_info is common_namespace_function_node)
             {
                 function_node fn = si.sym_info as function_node;
                 if (fn.return_value_type == to && fn.parameters.Count == 1 && fn.parameters[0].type == from)
                 {
                     return fn;
                 }
             }
             si = si.Next;
         }
     }
     return null;
 }
Example #2
0
 public static function_node get_explicit_conversion(compiled_type_node in_type, compiled_type_node from,
     compiled_type_node to, NetTypeScope scope)
 {
     return get_conversion(in_type, from, to, compiler_string_consts.explicit_operator_name, scope);
 }