Esempio n. 1
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);
        }
Esempio n. 2
0
        protected void Subroutine(PowerObject.Access access)
        {
            SkipWhite();
            string name = GetIdent();

            SkipWhite();
            powerScriptHolder.CreateFunction(name, access);
            Match('('); SkipWhite();
            if (!Peek(')'))
            {
                ParameterList();
            }
            Match(')'); SkipWhite();

            if (MatchMayBe("throws"))
            {
                SkipWhite();
                string except = GetIdent();
                powerScriptHolder.SetThrows(except);
                SkipWhite();
            }

            Match(';');
            StartFunction();
            Script("end subroutine");
            EndFunction();
            powerScriptHolder.FunctionFinished();
        }
Esempio n. 3
0
        protected void Function(PowerObject.Access access)
        {
            string type = GetIdent();

            SkipWhite();
            string name = GetIdent();

            SkipWhite();

            powerScriptHolder.CreateFunction(name, access, type);

            Match("("); SkipWhite();
            if (!Peek(")"))
            {
                ParameterList();
            }
            Match(")"); SkipWhite();

            if (MatchMayBe("throws"))
            {
                SkipWhite();
                string except = GetIdent();
                powerScriptHolder.SetThrows(except);
                SkipWhite();
            }

            Match(";");
            StartFunction();
            Script("end function");
            EndFunction();
            powerScriptHolder.FunctionFinished();
        }
        public void CreateFunction(string name, PowerObject.Access access, string returns)
        {
            Debug.Assert(this.compileInProgress == true);
            Debug.Assert(this.currentObject != null);

            ScriptFunction fun = new ScriptFunction(currentObject, name, access, returns);

            currentScriptBase = fun;
        }
Esempio n. 5
0
        protected void AccessModifier(PowerObject.Access access)
        {
            SkipWhite();
            GlobalKeyWords word = LookupKeyWords();

            SkipWhite();
            switch (word)
            {
            case GlobalKeyWords.Function:
                Function(access);
                break;

            case GlobalKeyWords.Subroutine:
                Subroutine(access);
                break;
            }
        }
Esempio n. 6
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name)
 {
     this.access = access;
     this.unresolvedReturnType = returns;
 }
Esempio n. 7
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access) : base(parent, name)
 {
     this.access = access;
 }
Esempio n. 8
0
        public ScriptFunction(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name, access, returns)
        {
            parent.AddFunction(this);

            documentation = new ScriptFunctionDoc(this);
        }