void Start() { instance = this; luaSvr = new LuaSvr();//LuaSvr创建luastate luastate创建IntPtr luaSvr.init(null, () => { luaSvr.start("interactiveLua");//luastate里面跑main函数 luaSvr.luaState.getFunction("PrintTxt").call("csPrintTxt"); luaSvr.luaState.getFunction("NoArgs").call(); }, LuaSvrFlag.LSF_DEBUG);//创建LuaObject }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { // X:\jsc.svn\examples\javascript\async\AsyncWindowUncaughtError\AsyncWindowUncaughtError\ApplicationWebService.cs // intellitrace // a self debugging programe? // can we have buttons for debugging? // https://www.youtube.com/watch?v=4vtKRE9an_I // could we have live patching, remote debugging via udp? var Next = new IHTMLButton { "Next" }.AttachToDocument(); Next.disabled = true; Func <Task> Next_onclick = async delegate { Next.disabled = false; await Next.async.onclick; Next.disabled = true; }; trace trace = async(string filepath, int linenumber, string line) => { // could we go backwards in time too? // like intellitrace? var debugged = new IHTMLPre { }.AttachToDocument(); // should we allow chaning constants? // by patching const load opcodes? var l = new IHTMLSpan { "" + linenumber }.AttachToDocument(); l.title = filepath; l.style.marginRight = "2em"; l.style.color = "darkcyan"; l.AttachTo(debugged); // could we use css to do syntax highlight? var prefixToHide = "await trace();"; // perhaps the next step would be to send us the origina stack usage IL // we see in the jsc reflector? var c = new IHTMLSpan { line.Replace(prefixToHide, "") }; c.style.marginRight = "2em"; //c.style.color = "blue"; c.style.backgroundColor = "yellow"; c.AttachTo(debugged); await Next_onclick(); c.style.backgroundColor = ""; }; interactive <string> __string = async(string data, string filepath, int linenumber, string line) => { var i = new IHTMLInput { value = data }.AttachToDocument(); await Next_onclick(); return(i.value); }; //Func<> Func <string, Task <string> > program = // a simulaton of a program async data => { await trace(); new IHTMLPre { await __string("hello") }.AttachToDocument(); await trace(); new IHTMLPre { await __string("world") }.AttachToDocument(); await trace(); return("done!"); }; new IHTMLButton { "Step Into" }.AttachToDocument().onclick += async e => { new IHTMLHorizontalRule().AttachToDocument(); e.Element.disabled = true; var value = await program("data"); e.Element.disabled = false; new IHTMLPre { new { value } }.AttachToDocument(); }; new IHTMLButton { "Run" }.AttachToDocument().onclick += async e => { // enum to string? new IHTMLHorizontalRule().AttachToDocument(); var x = Next_onclick; // slow down the program Next_onclick = async delegate { await Task.Delay(300); }; e.Element.disabled = true; var value = await program("data"); e.Element.disabled = false; Next_onclick = x; new IHTMLPre { new { value } }.AttachToDocument(); }; }