Ejemplo n.º 1
0
        public object createMethod(object theClass, string name, NClass.Core.Method method)
        {
            form.Clear_Undo();
            Procedure_Chart sbchrt = new Procedure_Chart(form, name, 0);

            sbchrt.method = method;
            (theClass as ClassTabPage).tabControl1.TabPages.Add(sbchrt);
            form.modified = true;
            return(sbchrt);
        }
Ejemplo n.º 2
0
 public void start_method(NClass.Core.Method method)
 {
     Indent();
     stream.WriteLine(method.GetDeclarationLine());
     Indent();
     stream.WriteLine("{");
     indent_level += 3;
     variables.Clear();
     arrays.Clear();
     arrays_2d.Clear();
     strings.Clear();
     current_method = method;
 }
Ejemplo n.º 3
0
 internal static int Suggestions(NClass.Core.CompositeType startingClass, string name, bool isStatic)
 {
     NClass.Core.CompositeType ct = startingClass;
     while (ct != null && !ct.Name.Equals("Object"))
     {
         foreach (NClass.Core.Field f in ct.Fields)
         {
             if ((f.IsStatic == isStatic) && f.Name.ToLower().StartsWith(name))
             {
                 oo_suggestion_list.Add(f.Name);
             }
         }
         foreach (NClass.Core.Operation o in ct.Operations)
         {
             if (o is NClass.Core.Method && (o.IsStatic == isStatic) &&
                 (!(o is NClass.Core.Constructor)) &&
                 o.Name.ToLower().StartsWith(name))
             {
                 NClass.Core.Method m = (o as NClass.Core.Method);
                 int      num_params;
                 string[] param_names;
                 bool[]   param_is_input;
                 bool[]   param_is_output;
                 System.Text.StringBuilder sb = new System.Text.StringBuilder();
                 sb.Append(m.Name + "(");
                 m.getParameters(out num_params, out param_names,
                                 out param_is_input, out param_is_output);
                 for (int i = 0; i < num_params; i++)
                 {
                     sb.Append(param_names[i]);
                     if (i < num_params - 1)
                     {
                         sb.Append(",");
                     }
                 }
                 sb.Append(")");
                 oo_suggestion_list.Add(sb.ToString());
             }
         }
         if (ct is NClass.Core.ClassType)
         {
             ct = (ct as NClass.Core.ClassType).BaseClass;
         }
         else
         {
             ct = null;
         }
     }
     return(oo_suggestion_list.Count);
 }
Ejemplo n.º 4
0
 public void Start_Method(string name)
 {
     current_method = null;
     if (name == "Main")
     {
         stream = main_stream;
         // I'm not sure how to work globals into the output.  This appears to be an abstract class that is
         // called by other methods in Martin's code.  I'll proceed with all local variables for now . . .
         Indent();
         stream.WriteLine("public static void main(String[] args)");
         Indent();
         stream.WriteLine("{");
     }
     else
     {
         Indent();
         // Without globals, we can't use static, or class methods; we can only use instance methods
         // Class methods can only act on global (static) variables
         MethodInformation mi = Procedures[name];
         if (hasReturnValue(mi, name))
         {
             stream.Write("public static ??");
             // finish writing method name with parameters if has return value
             // have to test for array return, cannot do here
         }
         else
         {
             stream.Write("public static void " + name + "(");
         }
     }
     variables.Clear();
     arrays.Clear();
     arrays_2d.Clear();
     strings.Clear();
     indent_level += 3;
 }
Ejemplo n.º 5
0
        public static void Init()
        {
            have_bold = false;
            current_suggestion_line = -1;
            list  = new System.Collections.Generic.List <string>();
            types = new System.Collections.Generic.Dictionary <string, string>();
            oo_suggestion_list = new System.Collections.Generic.List <string>();
            if (Runtime.parent.carlisle.SelectedTab is ClassTabPage)
            {
                ((Procedure_Chart)((ClassTabPage)Runtime.parent.carlisle.SelectedTab).tabControl1.SelectedTab).Start.collect_variable_names(list, types);
                NClass.Core.Method method = ((Procedure_Chart)((ClassTabPage)Runtime.parent.carlisle.SelectedTab).tabControl1.SelectedTab).method;
                if (method != null)
                {
                    for (int i = 0; i < method.numberArguments; i++)
                    {
                        NClass.Core.Parameter p = method.getParameter(i);
                        if (!types.ContainsKey(p.Name.ToLower()))
                        {
                            types.Add(p.Name.ToLower(), p.Type);
                        }
                    }
                }
            }
            else if (Runtime.parent.carlisle.SelectedTab is Procedure_Chart)
            {
                ((Procedure_Chart)Runtime.parent.carlisle.SelectedTab).Start.collect_variable_names(list, types);
            }
            else
            {
                for (int i = Runtime.parent.mainIndex; i < Runtime.parent.carlisle.TabCount; i++)
                {
                    if ((Runtime.parent.carlisle.TabPages[i] is Subchart) &&
                        !(Runtime.parent.carlisle.TabPages[i] is Procedure_Chart))
                    {
                        ((Subchart)Runtime.parent.carlisle.TabPages[i]).Start.collect_variable_names(list, types);
                    }
                }
            }
            if (Component.Current_Mode == Mode.Expert)
            {
                if (Runtime.parent.carlisle.SelectedIndex != 1)
                {
                    list.Add("this");
                    list.Add("super");
                }
                foreach (NClass.Core.IEntity ie in Runtime.parent.projectCore.Entities)
                {
                    if (ie is NClass.Core.ClassType)
                    {
                        list.Add(ie.Name);
                    }
                }
            }
            list.Sort();
            int k = 0;

            while (k < list.Count - 1)
            {
                if (list[k].ToLower() == list[k + 1].ToLower())
                {
                    list.Remove(list[k + 1]);
                }
                else
                {
                    k++;
                }
            }
        }
Ejemplo n.º 6
0
        private static void Do_Compilation_OO(Oval start, GeneratorAda.OO_Interface gil, TabControl.TabPageCollection tpc)
        {
            _tpc = tpc;
            foreach (NClass.Core.IEntity ie in Runtime.parent.projectCore.Entities)
            {
                if (ie is NClass.Core.InterfaceType)
                {
                    gil.start_interface(ie as NClass.Core.InterfaceType);
                    foreach (NClass.Core.Operation o in
                             (ie as NClass.Core.InterfaceType).Operations)
                    {
                        if (o is NClass.Core.Method)
                        {
                            gil.declare_interface_method(o as NClass.Core.Method);
                        }
                    }
                    gil.done_interface(ie as NClass.Core.InterfaceType);
                }
            }
            foreach (ClassTabPage ctp in allClasses(tpc))
            {
                gil.declare_class(ctp.ct);
                foreach (Procedure_Chart pc in allMethods(ctp))
                {
                    NClass.Core.Method method = pc.method;
                    gil.declare_method(method);
                }
            }
            foreach (ClassTabPage ctp in allClasses(tpc))
            {
                NClass.Core.ClassType ct = ctp.ct;
                gil.start_class(ct);
                foreach (NClass.Core.Field f in ct.Fields)
                {
                    gil.declare_field(f);
                }

                foreach (NClass.Core.Operation o in ct.Operations)
                {
                    if ((o is NClass.Core.Method) &&
                        o.IsAbstract)
                    {
                        gil.declare_abstract_method(o as NClass.Core.Method);
                    }
                }
                foreach (Procedure_Chart pc in allMethods(ctp))
                {
                    NClass.Core.Method method = pc.method;
                    gil.start_method(method);
                    declarations.Clear();
                    pc.Start.compile_pass1(gil);
                    gil.Done_Variable_Declarations();
                    pc.Start.Emit_Code(gil);
                    gil.Done_Method();
                }
                gil.done_class(ctp.ct);
            }

            gil.Start_Method("Main");
            declarations.Clear();
            start.compile_pass1(gil);
            gil.Done_Variable_Declarations();
            start.Emit_Code(gil);
            gil.Done_Method();
            gil.Finish();
        }
Ejemplo n.º 7
0
 public void declare_abstract_method(NClass.Core.Method method)
 {
     Indent();
     stream.WriteLine(method.GetDeclarationLine());
 }
Ejemplo n.º 8
0
 public void declare_method(NClass.Core.Method method)
 {
 }
Ejemplo n.º 9
0
 public void start_method(NClass.Core.Method method)
 {
     strings.Append("SM" + method.numberArguments);
 }
Ejemplo n.º 10
0
 public void declare_abstract_method(NClass.Core.Method method)
 {
 }