public ComputerModel BuildModel(Assembly asm) { // Reset previous registers QuantumParser.QuantumComputer localComp = QuantumParser.QuantumComputer.GetInstance(); ComputerModel emptyModel = ComputerModel.CreateModelForParser(); localComp.Reset(emptyModel); // Get the method Main MethodInfo method = asm.EntryPoint; try { // Call the static method Main to generate circuit method.Invoke(null, null); } catch (Exception ex) { StringBuilder builder = new StringBuilder("Circuit builder errors:\n\n"); builder.Append(ex.InnerException.GetType().ToString()).Append(": ").AppendLine(ex.InnerException.Message); throw new Exception(builder.ToString()); } ComputerModel generatedModel = localComp.GetModel(); generatedModel.AddStepAfter(generatedModel.Steps.Count - 1); return(generatedModel); }