public void VariableContextSearch() { LolCodeBlock blk = new LolCodeBlock(); LolCodeBlock chl_blk = new LolCodeBlock(blk); Assert.AreSame(blk, LolCodeBlock.GetNextVariableContext(blk), "same context"); Assert.AreSame(blk, LolCodeBlock.GetNextVariableContext(chl_blk), "child context"); }
public void VariableUninitialized() { LolCodeBlock blk = new LolCodeBlock(); blk.AddVariable("abc"); LolCodeValue tmp = blk.GetVariable("abc"); Assert.AreEqual(null, tmp.ValueType); }
public void VariableSearch() { LolCodeBlock blk = new LolCodeBlock(); LolCodeBlock chl_blk = new LolCodeBlock(blk); LolCodeValue tmp = (LolCodeValue)10; blk.AddVariable("abc"); blk.SetVariable("abc", tmp); Assert.AreSame(tmp, blk.GetVariable("abc"), "set main, get main"); Assert.AreSame(tmp, chl_blk.GetVariable("abc"), "set main, get child"); tmp = (LolCodeValue)20; chl_blk.AddVariable("def"); chl_blk.SetVariable("def", tmp); Assert.AreSame(tmp, blk.GetVariable("def"), "set child, get main"); Assert.AreSame(tmp, chl_blk.GetVariable("def"), "set child, get child"); }
public void Dispose() { main = null; Console.SetOut(new StreamWriter(Console.OpenStandardOutput())); }
private void _runParser(string program) { sw = new StringWriter(); Console.SetOut(sw); main = new LolCodeBlock(); tokens = new SlkToken(program, log); error = new SlkError(tokens, log); action = new SlkAction(tokens, main); SlkParser.parse(0, action, tokens, error, log, SlkConstants.NT_LOLCODE_); main.Run(); }
internal SlkAction(Scanner scanner, LolCodeBlock program_block) { _contexts.Push(program_block); _scanner = scanner; }
private void StartBlock() { LolCodeBlock nb = new LolCodeBlock(_contexts.Peek()); ((LolCodeBlock) _contexts.Peek()).Add(nb); _contexts.Push(nb); }