private void ValidateIfLockedAssignment(Block block) { if (_samode) { if (!(((ExpressionStatement)block.Children.First()).Expression is AssignmentExpression)) { throw new ArgumentException("Cannot enter locked assignment mode for a non-assignment expression."); } } }
public FuncDef(String name, IEnumerable<String> args, Block body) : base(AstNodeType.FuncDef, body.AsArray()) { Name = name; Args = args; }
private void _moveDownButton_Click(object sender, EventArgs e) { var oldIndex = SelectedLineIndex; var head = _root.Children.Take(SelectedLineIndex); var me = _root.Children.ElementAt(SelectedLineIndex); var swap = _root.Children.ElementAt(SelectedLineIndex + 1); var tail = _root.Children.Skip(SelectedLineIndex + 2); _root = new Block(head.Concat(swap.AsArray()) .Concat(me.AsArray()).Concat(tail).Cast<Statement>()); RebuildTopPanelContent(); SelectedLineIndex = oldIndex + 1; }
private void _deleteButton_Click(object sender, EventArgs e) { if (!this.Confirm()) return; var oldIndex = SelectedLineIndex; var head = _root.Children.Take(SelectedLineIndex); var tail = _root.Children.Skip(SelectedLineIndex + 1); _root = (Block)_root.ReplaceMeWith(() => new Block(head.Concat(tail).Cast<Statement>())); RebuildTopPanelContent(); SelectedLineIndex = oldIndex - 1; }
private void _addButton_Click(object sender, EventArgs e) { var expression = new AssignmentExpression(new VariableExpression("?"), new LiteralExpression("[[?]]?")); var oldIndex = SelectedLineIndex; var head = _root.Children.Take(oldIndex + 1); var @new = new ExpressionStatement(expression); var tail = _root.Children.Skip(oldIndex + 1); var newchi = head.Concat(@new.AsArray()).Concat(tail).Cast<Statement>(); _root = (Block)_root.ReplaceMeWith(() => new Block(newchi)); RebuildTopPanelContent(); SelectedLineIndex = oldIndex + 1; }
public IfStatement(Expression test, Block then, Block @else) : base(AstNodeType.IfStatement, new AstNode[]{test, then, @else}) { }
private IEnumerable<ElfVmInstruction> CompileBlock(Block b) { yield return new Enter(); foreach (var stmt in b.Statements) foreach (var evi in Compile(stmt)) yield return evi; yield return new Leave(); }