예제 #1
0
파일: ElfEditor.cs 프로젝트: xeno-by/elf4b
        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;
        }
예제 #2
0
        private IEnumerable<ElfVmInstruction> CompileExpression(ExpressionStatement es)
        {
            // todo. would be nice to somehow guard ourselves against useless expressions, but how?
            // so far any expression can be meaningful because of side-effects

            foreach (var evi in Compile(es.Expression))
                yield return evi;

            // every expression results in a value on the stack
            // when we abandon the expression, we should get rid of that value
            yield return new Pop();
        }