コード例 #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
ファイル: DefaultElfCompiler.cs プロジェクト: xeno-by/elf4b
        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();
        }