Ejemplo 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);
        }
Ejemplo 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();
        }
Ejemplo 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;
        }
Ejemplo 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;
            }
        }
Ejemplo n.º 6
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name)
 {
     this.access = access;
     this.unresolvedReturnType = returns;
 }
Ejemplo n.º 7
0
 public ScriptBase(PowerObject parent, string name, PowerObject.Access access) : base(parent, name)
 {
     this.access = access;
 }
Ejemplo 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);
        }