public void CreateUnresolvedLocalType(string name, string super, string parent)
        {
            Debug.Assert(this.compileInProgress == true);
            Debug.Assert(this.currentObject != null);
            PowerObject new_object;
            PowerObject parent_class;

            if (parent != currentObject.Name)
            {
                PowerObject obj = currentObject;
                do
                {
                    parent_class = obj.GetChildClass(parent);
                    obj          = obj.ParentClass;
                } while (parent_class == null && obj != null);
                if (parent_class == null)
                {
                    parent_class = Namespace.GetObject(parent);
                }
            }
            else
            {
                parent_class = currentObject;
            }

            // TODO: osetrit vyjimkou pripad, kdy je parent_class null; znamenalo by to, ze neni znam
            // rodic (trida, v kterem je vytvarena trida umistena) - ten musi byt znam vzdy
            new_object    = new PowerObject(currentObject, name, super, parent_class);
            currentObject = new_object;
        }
Example #2
0
        static void PrintUserDefinedObjectsStructure(PowerObject root)
        {
            if (!root.IsHardwired)
            {
                // potomci uzivatelsky definovaneho objektu nemohou byt hardwired
                if (root.ParentClass == null)
                {
                    // vynechani vsech trid, ktere jsou obsazeny v jinem objektu
                    Trace.WriteLine(root.Name);
                    Trace.Indent();
                    foreach (PowerObject obj in root.ChildObjects)
                    {
                        PrintObjectStructure(obj);
                    }
                    PrintEvents(root);
                    PrintFunctions(root);
                    Trace.Unindent();

                    // vypis vsech oddedenych objektu
                    foreach (PowerObject obj in root.InheritedObjects)
                    {
                        PrintUserDefinedObjectsStructure(obj);
                    }
                }
            }
            else
            {
                foreach (PowerObject obj in root.InheritedObjects)
                {
                    PrintUserDefinedObjectsStructure(obj);
                }
            }
        }
Example #3
0
        public void Resolve()
        {
            if (!this.IsUnresolved)
            {
                return;
            }

            this.superClass = Namespace.GetObject(this.unresolvedSuperClass);
            if (this.superClass == null)
            {
                // TODO: jmeno predka bude v kompozitni forme (tzn. predek.vnorena trida)
                this.superClass = null;
                int pos;

                pos = this.unresolvedSuperClass.IndexOf('.');
                if (pos > 0)
                {
                    string unresolved = this.unresolvedSuperClass.Substring(pos + 1, unresolvedSuperClass.Length - pos - 1);
                    this.parentClass.superClass.Resolve();                     // zde se muze stat, ze this.parentClass.superClass jeste neni resolved
                    this.superClass = this.parentClass.superClass.GetChildClass(unresolved);
                }
            }

            if (this.superClass == null)
            {
                Trace.WriteLine("Predek " + this.unresolvedSuperClass + " objektu " + this.FullName + " nebyl nalezen. Bude formalne nahrazen tridou PowerObject.");
                this.superClass = PowerObject.PowerObjectInstance;
            }

            this.superClass.AddInheritedClass(this);

            ResolveChildObjects();
            ResolveFunctions();
            ResolveEvents();
        }
Example #4
0
        public PowerObject GetChildClass(string name)
        {
            // vychazi se z predpokladu, ze jmena vnorenych trid musi byt unikatni
            PowerObject child = childClasses[name] as PowerObject;

            if (child == null)
            {
                foreach (PowerObject obj in this.ChildObjects)
                {
                    child = obj.GetChildClass(name);
                    if (child != null)
                    {
                        return(child);
                    }
                }
            }
            else
            {
                return(child);
            }

            if (this.SuperClass != null)
            {
                return(this.SuperClass.GetChildClass(name));
            }

            return(null);
        }
Example #5
0
        public int GetFunctionsCount(bool count_super, PowerObject.Access access)
        {
            int         count = 0;
            PowerObject obj   = this;

            while (obj != null)
            {
                foreach (ScriptFunction fun in obj.Functions)
                {
                    if (fun.Access == access)
                    {
                        count++;
                    }
                }
                if (count_super)
                {
                    obj = obj.superClass;
                }
                else
                {
                    obj = null;
                }
                if (obj != null)
                {
                    count += obj.GetFunctionsCount(count_super, access);
                }
            }

            return(count);
        }
Example #6
0
        protected PowerObject(IPBContainer parent, string name) : base(parent.GetParent(), name)
        {
            this.parentClass = null;
            Namespace.AddObject(this);

            functionsEnumerable = new ScriptFunctionsEnumerable(scriptFunctions);
            this.documentation  = new PowerObjectDoc(this);
        }
Example #7
0
 public void Resolve()
 {
     if (this.IsUnresolved)
     {
         variableType   = this.GetObject(unresolvedType);
         unresolvedType = null;
     }
 }
Example #8
0
 static void PrintFunctions(PowerObject obj)
 {
     foreach (ScriptFunction fun in obj.Functions)
     {
         Trace.Write(fun.Name);
         PrintArguments(fun);
         Trace.WriteLine("");
     }
 }
Example #9
0
 static void PrintEvents(PowerObject obj)
 {
     foreach (ScriptEvent ev in obj.Events)
     {
         Trace.Write(ev.Name);
         PrintArguments(ev);
         Trace.WriteLine("");
     }
 }
Example #10
0
        public PowerObject(IPBContainer parent, string name, string super_class, PowerObject parent_class) : base(parent.GetParent(), name)
        {
            unresolvedSuperClass = super_class.ToLower();
            parent_class.AddChildClass(this);
            this.parentClass = parent_class;

            functionsEnumerable = new ScriptFunctionsEnumerable(scriptFunctions);
            this.documentation  = new PowerObjectDoc(this);
        }
        public void CreateUnresolvedLocalType(string name, string super)
        {
            Debug.Assert(this.compileInProgress == true);
            Debug.Assert(this.currentObject != null);
            PowerObject old_obj = this.currentObject;

            CreateUnresolvedLocalType(name, super, currentObject.Name);
            this.currentObject = old_obj;
        }
        public void CreateUnresolvedGlobalType(string name, string super)
        {
            Debug.Assert(this.compileInProgress == true);
            PowerObject new_object;

            new_object    = new PowerObject(this, name, super);
            currentObject = new_object;
            mainObject    = currentObject;
        }
Example #13
0
 static void PrintObjectHierarchy(PowerObject root)
 {
     Trace.WriteLine(root.Name);
     Trace.Indent();
     foreach (PowerObject obj in root.InheritedObjects)
     {
         PrintObjectHierarchy(obj);
     }
     Trace.Unindent();
 }
Example #14
0
 static void PrintObjectStructure(PowerObject root)
 {
     Trace.WriteLine(root.Name);
     Trace.Indent();
     foreach (PowerObject obj in root.ChildObjects)
     {
         PrintObjectStructure(obj);
     }
     Trace.Unindent();
 }
Example #15
0
        public virtual void Resolve()
        {
            if (this.IsUnresolved)
            {
                returnType = GetObject(unresolvedReturnType);
            }
            ResolveArguments();

            if (unresolvedThrows != null)
            {
                throws = GetObject(unresolvedThrows);
                // TODO: otestovat zda typ existuje
                unresolvedThrows = null;
            }
        }
Example #16
0
        public override void Resolve()
        {
            base.Resolve();

            PowerObject obj = ( PowerObject )this.Parent;

            if (obj.GetFunctionOverloadCount(this.Name) > 1)
            {
                overloaded = true;
            }
            else
            {
                overloaded = false;
            }
        }
Example #17
0
        public ArrayList GetAllSuperClasses()
        {
            ArrayList   super_list = null;
            PowerObject super      = this.superClass;

            while (super != null)
            {
                if (super_list == null)
                {
                    super_list = new ArrayList();
                }
                super_list.Add(super);
                super = super.superClass;
            }

            return(super_list);
        }
Example #18
0
        public int GetFunctionOverloadCount(string name)
        {
            PowerObject obj   = this;
            int         count = 0;

            while (obj != null)
            {
                if (obj.scriptFunctions.ContainsKey(name))
                {
                    ArrayList list = obj.scriptFunctions[name] as ArrayList;
                    count += list.Count;
                }
                obj = obj.superClass;
            }

            return(count);
        }
Example #19
0
        public PowerObject(IPBContainer parent, string name, PowerObject super_class, PowerObject parent_class) : base(parent.GetParent(), name)
        {
            this.parentClass = parent_class;
            this.superClass  = super_class;

            if (parent_class != null)
            {
                parent_class.AddChildClass(this);
            }
            if (super_class == null)
            {
                // TODO: super_class musi byt PowerObject
            }
            super_class.AddInheritedClass(this);

            functionsEnumerable = new ScriptFunctionsEnumerable(scriptFunctions);
            this.documentation  = new PowerObjectDoc(this);
        }
Example #20
0
        public int GetFunctionsCount(bool count_super)
        {
            if (count_super)
            {
                int         count = this.FunctionsCount;
                PowerObject super = this.superClass;
                while (super != null)
                {
                    count += super.FunctionsCount;
                    super  = super.superClass;
                }

                return(count);
            }
            else
            {
                return(this.FunctionsCount);
            }
        }
Example #21
0
        protected PowerObject GetObject(string name)
        {
            PowerObject obj = Namespace.GetObject(name);

            if (obj == null)
            {
                PowerObject parent_obj = ( PowerObject )this.Parent;
                obj = parent_obj.GetLocalObject(name);
            }

            // TODO: nahradit exception
            if (obj == null)
            {
                Trace.WriteLine("Neznamy datvoy typ " + name + " bude formalne nahrazen typem structure");
                obj = Namespace.GetObject("structure");
            }

            return(obj);
        }
        public void CreateEventInParent(string name, string returns, string parent)
        {
            Debug.Assert(this.compileInProgress == true);
            Debug.Assert(this.currentObject != null);

            PowerObject new_obj = currentObject.TopParentClass.GetChildClass(parent);

            if (new_obj != null)
            {
                PowerObject old_obj = currentObject;
                currentObject = new_obj;
                CreateEvent(name, returns);
                currentObject = old_obj;
            }
            else
            {
                Trace.WriteLine("Neni mozne nalezt tridu " + parent + " pro vytvoreni eventu " + name + " (" + currentObject.FullName + ")");
            }
        }
Example #23
0
 static void PrintUserDefinedObjectsHierarchy(PowerObject root)
 {
     if (!root.IsHardwired)
     {
         // potomci uzivatelsky definovaneho objektu nemohou byt hardwired
         Trace.WriteLine(root.Name);
         Trace.Indent();
         foreach (PowerObject obj in root.InheritedObjects)
         {
             PrintObjectHierarchy(obj);
         }
         Trace.Unindent();
     }
     else
     {
         foreach (PowerObject obj in root.InheritedObjects)
         {
             PrintUserDefinedObjectsHierarchy(obj);
         }
     }
 }
        protected PBRoot TryStandard(ReferenceLink link)
        {
            Library lib = TryLibrary(link);

            if (lib != null)
            {
                return(lib);
            }

            PowerObject obj = TryPowerObject(link);

            if (obj != null)
            {
                return(obj);
            }

            obj = TryNestedPowerObject(link);
            if (obj != null)
            {
                return(obj);
            }

            ScriptBase script = TryScriptBase(link);

            if (script != null)
            {
                return(script);
            }

            PBRoot root = TryFullName(link);

            if (root != null)
            {
                return(root);
            }

            return(null);
        }
Example #25
0
        public ScriptEvent(PowerObject parent, string name, string returns) : base(parent, name, PowerObject.Access.Public, returns)
        {
            parent.AddEvent(this);

            documentation = new ScriptEventDoc(this);
        }
Example #26
0
        public ScriptFunction(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name, access, returns)
        {
            parent.AddFunction(this);

            documentation = new ScriptFunctionDoc(this);
        }
Example #27
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access) : base(parent, name)
 {
     this.access = access;
 }
Example #28
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name)
 {
     this.access = access;
     this.unresolvedReturnType = returns;
 }
Example #29
0
 public PowerObjectDoc(PowerObject parent) : base(parent)
 {
 }
Example #30
0
 public static void AddObject(PowerObject obj)
 {
     objects.Add(obj.Name, obj);
 }