Beispiel #1
0
 public static string GetSignature(string name, MosaMethodSignature sig, bool shortSig)
 {
     StringBuilder result = new StringBuilder();
     if (shortSig)
     {
         result.Append(name);
         result.Append("(");
         for (int i = 0; i < sig.Parameters.Count; i++)
         {
             if (i != 0)
                 result.Append(", ");
             result.Append(sig.Parameters[i].ParameterType.Name);
         }
         result.Append(") : ");
         result.Append(sig.ReturnType.Name);
         return result.ToString();
     }
     else
     {
         result.Append(sig.ReturnType.FullName);
         result.Append(" ");
         result.Append(name);
         result.Append("(");
         for (int i = 0; i < sig.Parameters.Count; i++)
         {
             if (i != 0)
                 result.Append(", ");
             result.Append(sig.Parameters[i].ParameterType.FullName);
         }
         result.Append(")");
         return result.ToString();
     }
 }
        public static MosaType ToFnPtr(this TypeSystem typeSystem, MosaMethodSignature signature)
        {
            MosaType result = typeSystem.Controller.CreateType();
            using (var ptrType = typeSystem.Controller.MutateType(result))
            {
                ptrType.Module = typeSystem.LinkerModule;
                ptrType.Namespace = "";
                ptrType.Name = "";

                ptrType.TypeCode = MosaTypeCode.FunctionPointer;
                ptrType.FunctionPtrSig = signature;

                return result;
            }
        }