Beispiel #1
0
        private void SynthsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Dat10Synth synth = (Dat10Synth)SynthsComboBox.SelectedItem;

            if (synth == null)
            {
                return;
            }

            loadingSynth = true;

            SynthTextBox.Text = Dat10Synth.Disassemble(synth.Bytecode, synth.Constants, synth.Variables, false).Disassembly;
            SynthTextBox.ClearUndo();
            SynthAssemblySyntaxHighlight(SynthTextBox.Range);

            SynthVariablesTextBox.Clear();
            SynthVariablesTextBox.Text = string.Join(Environment.NewLine, synth.Variables.Select(v => $"{RelXml.HashString(v.Name)} {FloatUtil.ToString(v.Value)}"));

            SynthOutputsTextBox.Clear();
            SynthOutputsTextBox.Text = string.Join(" ", synth.OutputsIndices.Take(synth.OutputsCount).Select(bufferIdx => $"B{bufferIdx}"));

            currentSynth = synth;

            loadingSynth = false;
        }
Beispiel #2
0
        private Dat10Synth AssembleSynth()
        {
            var outputs   = ParseSynthOutputs();
            var variables = ParseSynthVariables();

            bool error  = false;
            var  result = Dat10Synth.Assemble(SynthTextBox.Text, variables, (errorMsg, lineNumber) => error = true);

            if (error)
            {
                return(null);
            }

            currentSynth = new Dat10Synth(CurrentFile)
            {
                BuffersCount     = result.BuffersCount,
                RegistersCount   = result.RegistersCount,
                StateBlocksCount = result.StateBlocksCount,
                ConstantsCount   = result.Constants.Count,
                Constants        = result.Constants.ToArray(),
                Bytecode         = result.Bytecode,
                OutputsCount     = outputs.Length,
                OutputsIndices   = outputs,
                VariablesCount   = variables.Length,
                Variables        = variables,
                RuntimeCost      = 123
            };

            return(currentSynth);
        }
Beispiel #3
0
        private void SynthTextBox_TextChangedDelayed(object sender, TextChangedEventArgs e)
        {
            string errors = "";

            SynthTextBox.Range.ClearStyle(ErrorStyle);
            SynthAssemblySyntaxHighlight(SynthTextBox.Range);
            var variables = ParseSynthVariables();

            Dat10Synth.Assemble(SynthTextBox.Text, variables, (errorMsg, lineNumber) =>
            {
                errors  += $"Line {lineNumber}: {errorMsg}" + Environment.NewLine;
                var line = SynthTextBox.GetLine(lineNumber - 1);
                line.ClearStyle(GreenStyle, OrangeRedStyle, BlueStyle, MaroonStyle, RedStyle);
                line.SetStyle(ErrorStyle);
            });
            StatusLabel.Text = errors;
        }