OSDN Git Service

Initial contents of nt2chview
[nt2chview/stable.git] / NT2chCtrl45 / html / js / JsParser.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 \r
5 namespace NT2chCtrl.html.js\r
6 {\r
7     partial class JsParser\r
8     {\r
9         //List<JsFunction> mBodyLvlFunc = new List<JsFunction>();\r
10         List<JsRootFunction> mFuncList = new List<JsRootFunction>();\r
11         //HtmlElement mRootElement;\r
12         public bool PreCompile(DebugContext ctx , HtmlElement jsElem)\r
13         {\r
14             string[] contents = jsElem.getStringContent();\r
15             if (contents == null || contents.Length != 1)\r
16                 return false;\r
17 \r
18             JsRootFunction rootFunc = new JsRootFunction(ctx.mCurrentLine, 0);\r
19             if (rootFunc.Parse(ctx, contents[0]))\r
20             {\r
21                 mFuncList.Add(rootFunc);\r
22                 return true;\r
23             }\r
24             else\r
25             {\r
26                 return false;\r
27             }\r
28         }\r
29 \r
30         public bool run(DebugContext dCtx, HtmlElement rootElement, out JsFunctionContext fCtx)\r
31         {\r
32             fCtx = null;\r
33             if (mFuncList.Count == 0)\r
34                 return true;\r
35 \r
36             foreach (JsRootFunction func in mFuncList)\r
37             {\r
38                 fCtx = new JsFunctionContext(dCtx);\r
39                 if (func.getInstaructionCount() > 0 && \r
40                     null == func.Execute(fCtx, rootElement))\r
41                 {\r
42                     return false;\r
43                 }\r
44             }\r
45             return true;\r
46         }\r
47     }\r
48 }\r