public void TestNakoILWriter1() { NakoCompiler ns = new NakoCompiler(); NakoILWriter writer = new NakoILWriter(null); bool r; // (1) ns.source = "1+2*3"; ns.Tokenize(); ns.ParseOnlyValue(); writer.Write(ns.TopNode); r = writer.Result.CheckTypes(new NakoILType[] { NakoILType.NOP, NakoILType.LD_CONST_INT, NakoILType.LD_CONST_INT, NakoILType.LD_CONST_INT, NakoILType.MUL, NakoILType.ADD }); Assert.IsTrue(r); }
/// <summary> /// 構文解析の行われた TopNode に対して、ILコードの発行を行う /// 結果は、Codes に得られる /// </summary> public NakoILCodeList WriteIL() { var writer = new NakoILWriter(); writer.Write(this.topNode); codes = writer.Result; codes.globalVar = this.GlobalVar; return Codes; }