Ejemplo n.º 1
0
 private InteractiveTypeSpec instantiate_type(InteractiveTypeSpec ts)
 {
     if (ts.ts.IsGenericTemplate)
     {
         TypeSpec[] gtparams = new TypeSpec[ts.ts.GenericParamCount];
         for (int i = 0; i < ts.ts.GenericParamCount; i++)
         {
             string[] cmd;
             ach.JustType = true;
             while ((cmd = get_command("GP" + i.ToString() + "> ")).Length == 0)
             {
                 ;
             }
             ach.JustType = false;
             int idx  = 0;
             var type = ParseType(cmd, ref idx);
             gtparams[i] = type;
         }
         ts.ts.gtparams = gtparams;
         return(ts);
     }
     else
     {
         return(ts);
     }
 }
Ejemplo n.º 2
0
        private InteractiveTypeSpec ParseType(string[] cmd, ref int idx, InteractiveState state = null)
        {
            if (state == null)
            {
                state = s;
            }
            if (idx >= cmd.Length || cmd[idx] == ":")
            {
                return(state.ts);
            }

            var tname = cmd[idx++];

            InteractiveTypeSpec new_ts = null;

            if (state.m.AllTypes.ContainsKey(tname))
            {
                new_ts = state.m.AllTypes[tname];
            }
            else if (corlib.AllTypes.ContainsKey(tname))
            {
                new_ts = corlib.AllTypes[tname];
            }

            if (new_ts == null)
            {
                Console.WriteLine("Type: " + tname + " not found in " + state.m.m.AssemblyName);
                return(state.ts);
            }

            if (idx < cmd.Length)
            {
                if (cmd[idx] == "<")
                {
                    // handle generics
                    idx++;
                    var gtparams = new List <TypeSpec>();
                    while (cmd[idx] != ">")
                    {
                        gtparams.Add(ParseType(cmd, ref idx, state));
                        if (cmd[idx] == ",")
                        {
                            idx++;
                        }
                    }
                    idx++;
                    new_ts.ts.gtparams = gtparams.ToArray();
                }
            }

            return(new_ts);
        }