Example #1
0
 private static void findAndCallConstructor(
     string name,
     parse_tree.parameter_list parameters,
     ClassTabPage ctp, int count, NClass.Core.ClassType theClass)
 {
     foreach (NClass.Core.Operation op in theClass.Operations)
     {
         if (op is NClass.Core.Constructor)
         {
             if ((op as NClass.Core.Constructor).numberArguments == count)
             {
                 Procedure_Chart sc = (op as NClass.Core.Constructor).raptorTab
                                      as Procedure_Chart;
                 if (sc != null)
                 {
                     Runtime.Set_Running(sc);
                     Invoke_Tab_Procedure_Enter(
                         parameters, sc, Runtime.getContext());
                     CallStack.setContext(Runtime.getContext());
                     return;
                 }
             }
         }
     }
     throw new System.Exception("could not find constructor for " + name +
                                " with " + count + " parameter(s).");
 }
Example #2
0
        public object createClass(string name, NClass.Core.ClassType ct)
        {
            form.Clear_Undo();
            ClassTabPage ctp = new ClassTabPage(form, name);

            ctp.ct = ct;
            form.carlisle.TabPages.Add(ctp);
            form.modified = true;
            return(ctp);
        }
Example #3
0
 public void declare_class(NClass.Core.ClassType ct)
 {
     try
     {
         classes.Add(ct.Name, ct);
     }
     catch
     {
     }
     current_class = ct;
 }
Example #4
0
        public void start_class(NClass.Core.ClassType ct)
        {
            //int i,int_count;
            string class_file_name;

            current_class   = ct;
            class_file_name = System.IO.Path.Combine(
                directory_name,
                ct.Name + ".java");
            stream = File.CreateText(class_file_name);
            CreateFileComment();
            stream.WriteLine(ct.GetDeclarationLine());

            /*stream.Write("public class " + ct.Name);
             * if (!ct.BaseClass.Name.Equals("Object"))
             * {
             *  stream.Write(" extends " + ct.BaseClass.Name);
             * }
             * int_count = 0;
             * foreach (NClass.Core.InterfaceType intrfce in ct.Interfaces)
             * {
             *  int_count++;
             * }
             * if (int_count > 0)
             * {
             *  i = 0;
             *  stream.Write(" implements ");
             *  foreach (NClass.Core.InterfaceType intrfce in ct.Interfaces)
             *  {
             *      i++;
             *      stream.Write(intrfce.Name);
             *      if (i < int_count)
             *      {
             *          stream.Write(", ");
             *      }
             *  }
             * }*/
            stream.WriteLine();
            stream.WriteLine("{");
            // sets current depth of an indent
            indent_level = 3;
        }
Example #5
0
        public static bool Invoke_Constructor(string name, parse_tree.parameter_list parameters)
        {
            int count = parse_tree_pkg.count_parameters(parameters);

            NClass.Core.ClassType theClass = Runtime.parent.projectCore.findClass(name);
            while (theClass != null)
            {
                foreach (NClass.Core.Operation op in theClass.Operations)
                {
                    if (op is NClass.Core.Constructor)
                    {
                        if ((op as NClass.Core.Constructor).numberArguments == count)
                        {
                            Procedure_Chart sc = (op as NClass.Core.Constructor).raptorTab
                                                 as Procedure_Chart;
                            if (sc != null)
                            {
                                Runtime.Set_Running(sc);
                                Runtime.Variable this_value = Runtime.getContext();
                                Runtime.setContext(null);
                                // we stored the "this" parameter in the context
                                // but need to set it to null before entering the
                                // method
                                Invoke_Tab_Procedure_Enter(parameters, sc, this_value);
                                CallStack.setContext(Runtime.getContext());
                                return(true);
                            }
                        }
                    }
                }
                theClass = theClass.BaseClass;
            }
            if (count == 0)
            {
                return(false);
            }
            else
            {
                throw new System.Exception("could not find constructor for " + name +
                                           " with " + count + " parameter(s).");
            }
        }
Example #6
0
        public static void Invoke_This_Constructor(parse_tree.parameter_list parameters)
        {
            ClassTabPage ctp = Runtime.parent.currentClass();

            if (ctp == null)
            {
                throw new System.Exception("no constructor in " + Runtime.parent.running_tab.Text);
            }
            if (state == State_Enum.Entering)
            {
                int count = parse_tree_pkg.count_parameters(parameters);
                NClass.Core.ClassType theClass = Runtime.parent.projectCore.findClass(ctp.Text);
                findAndCallConstructor(
                    theClass.Name, parameters, ctp, count, theClass);
            }
            else
            {
                call_rect.running = false;
            }
        }
Example #7
0
        internal static int Prefix_Suggestion_Count(string name)
        {
            oo_suggestion_list.Clear();
            int index = name.IndexOf('.');

            if (name.LastIndexOf('.') != index)
            {
                return(0);
            }
            if (name.StartsWith("this."))
            {
                if (Runtime.parent.carlisle.SelectedTab is ClassTabPage &&
                    ((Runtime.parent.carlisle.SelectedTab as ClassTabPage).tabControl1.SelectedTab
                     as Procedure_Chart).method != null)
                {
                    NClass.Core.ClassType ct =
                        ((Runtime.parent.carlisle.SelectedTab as ClassTabPage).tabControl1.SelectedTab
                         as Procedure_Chart).method.Parent
                        as NClass.Core.ClassType;
                    return(Suggestions(ct, name.Substring(index + 1), false));
                }
            }
            else if (name.StartsWith("super."))
            {
                if (Runtime.parent.carlisle.SelectedTab is ClassTabPage &&
                    ((Runtime.parent.carlisle.SelectedTab as ClassTabPage).tabControl1.SelectedTab
                     as Procedure_Chart).method != null)
                {
                    NClass.Core.ClassType ct =
                        ((Runtime.parent.carlisle.SelectedTab as ClassTabPage).tabControl1.SelectedTab
                         as Procedure_Chart).method.Parent
                        as NClass.Core.ClassType;
                    return(Suggestions(ct.BaseClass, name.Substring(index + 1), false));
                }
            }
            else
            {
                foreach (NClass.Core.IEntity ie in Runtime.parent.projectCore.Entities)
                {
                    if (name.StartsWith(ie.Name.ToLower() + "."))
                    {
                        if (ie is NClass.Core.CompositeType)
                        {
                            NClass.Core.CompositeType ct = ie as NClass.Core.CompositeType;
                            return(Suggestions(ct, name.Substring(index + 1), true));
                        }
                        else if (ie is NClass.Core.EnumType)
                        {
                            NClass.Core.EnumType et = ie as NClass.Core.EnumType;
                        }
                    }
                }
                if (types.ContainsKey(name.Substring(0, index).ToLower()))
                {
                    string typename = types[name.Substring(0, index).ToLower()];
                    foreach (NClass.Core.IEntity ie in Runtime.parent.projectCore.Entities)
                    {
                        if (ie.Name.ToLower().Equals(typename.ToLower()))
                        {
                            if (ie is NClass.Core.CompositeType)
                            {
                                NClass.Core.CompositeType ct = ie as NClass.Core.CompositeType;
                                return(Suggestions(ct, name.Substring(index + 1), false));
                            }
                            else if (ie is NClass.Core.EnumType)
                            {
                            }
                        }
                    }
                }
            }
            return(0);
        }
Example #8
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();
        }
Example #9
0
 public void done_class(NClass.Core.ClassType ct)
 {
     stream.WriteLine("} // close " + ct.Name);
     stream.Close();
 }
Example #10
0
 public void done_class(NClass.Core.ClassType ct)
 {
 }
Example #11
0
 public void start_class(NClass.Core.ClassType ct)
 {
 }
Example #12
0
 public void declare_class(NClass.Core.ClassType ct)
 {
 }