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); }
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(); }
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; }
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; } }
public ScriptBase(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name) { this.access = access; this.unresolvedReturnType = returns; }
public ScriptBase(PowerObject parent, string name, PowerObject.Access access) : base(parent, name) { this.access = access; }
public ScriptFunction(PowerObject parent, string name, PowerObject.Access access, string returns) : base(parent, name, access, returns) { parent.AddFunction(this); documentation = new ScriptFunctionDoc(this); }