Esempio n. 1
0
        /// <summary>
        /// Simulates a function/operation using the ToffoliSimulator as target machine.
        /// It expects a single input: the name of the function/operation to simulate.
        /// </summary>
        public async Task <ExecutionResult> RunAsync(string input, IChannel channel)
        {
            var(name, args) = ParseInput(input);

            var symbol = SymbolResolver.Resolve(name) as IQSharpSymbol;

            if (symbol == null)
            {
                throw new InvalidOperationException($"Invalid operation name: {name}");
            }

            var qsim = new ToffoliSimulator();

            qsim.DisableLogToConsole();
            qsim.OnLog += channel.Stdout;

            var value = await symbol.Operation.RunAsync(qsim, args);

            return(value.ToExecutionResult());
        }
Esempio n. 2
0
        /// <summary>
        /// Simulates a function/operation using the ToffoliSimulator as target machine.
        /// It expects a single input: the name of the function/operation to simulate.
        /// </summary>
        public async Task <ExecutionResult> RunAsync(string input, IChannel channel)
        {
            var inputParameters = ParseInputParameters(input, firstParameterInferredName: ParameterNameOperationName);

            var name   = inputParameters.DecodeParameter <string>(ParameterNameOperationName);
            var symbol = SymbolResolver.Resolve(name) as IQSharpSymbol;

            if (symbol == null)
            {
                throw new InvalidOperationException($"Invalid operation name: {name}");
            }

            var qsim = new ToffoliSimulator().WithStackTraceDisplay(channel);

            qsim.DisableLogToConsole();
            qsim.OnLog += channel.Stdout;

            var value = await symbol.Operation.RunAsync(qsim, inputParameters);

            return(value.ToExecutionResult());
        }