public InstructionViewModel() { Debug.WriteLine("Constructing InstructionViewModel."); IList<Instruction> list = new List<Instruction>(); model = new InstructionModel(list); library_names = new List<string>(); thread_ids = new List<uint>(); }
public async Task <int> CreateAsync(InstructionModel model) { do { model.Code = CodeGenerator.Generate(); }while (DbSet.Any(d => d.Code.Equals(model.Code))); InstructionLogic.CreateModel(model); return(await DbContext.SaveChangesAsync()); }
public InstructionViewModel() { Debug.WriteLine("Constructing InstructionViewModel."); IList <Instruction> list = new List <Instruction>(); model = new InstructionModel(list); library_names = new List <string>(); thread_ids = new List <uint>(); }
public IActionResult UpdateRecipe(RecipeModel recipe, string ingredientCSV, string instructionCSV) { recipe.Ingredients = IngredientModel.ingredientCSVtoDTO(ingredientCSV).ToList(); recipe.Instructions = InstructionModel.instructionCSVtoDTO(instructionCSV).ToList(); recipeManager.Update(RecipeModel.ModelToDto(recipe)); return(RedirectToAction("RecipeIndex")); }
public void ConditionalSkipTest(int programCounterInitial, bool inputValue, int expectedProgramCounter) { var instruction = new ConditionalSkipInstruction(); var instructionModel = new InstructionModel() { Type = instruction.Type, Data = 0, }; var context = new InstructionExecutionContext(new bool[] { inputValue }, programCounterInitial, instructionModel); var result = instruction.Execute(context); Assert.Equal(expectedProgramCounter, result.ProgramCounter); }
public void JumpTest(int programCounterInitial, int address) { var instruction = new JumpInstruction(); var instructionModel = new InstructionModel() { Type = instruction.Type, Data = address, }; var context = new InstructionExecutionContext(new bool[0], programCounterInitial, instructionModel); var result = instruction.Execute(context); Assert.Equal(address, result.ProgramCounter); }
public void ClearOutputTest(int programCounter) { var instruction = new ClearMemoryInstruction(); var instructionModel = new InstructionModel { Type = instruction.Type, Data = 0 }; var context = new InstructionExecutionContext(new bool[] { true }, programCounter, instructionModel); var result = instruction.Execute(context); Assert.False(context.Memory[0]); Assert.Equal(programCounter + 1, result.ProgramCounter); }
public override List <InstructionModel> GetInstructions(CompilationModel model) { var instructions = new List <InstructionModel>(); if (Expression != null) { instructions.AddRange(Expression.GetInstructions(model)); var type = Expression.GetExpressionType(model); var instruction = new InstructionModel(type == BuiltinTypes.Integer ? Instructions.ReturnIntInstruction : Instructions.ReturnPointerInstruction); instruction.Comment = model.GetComment(this); instructions.Add(instruction); } else { var instruction = new InstructionModel(Instructions.ReturnInstruction); instruction.Comment = model.GetComment(this); instructions.Add(instruction); } return(instructions); }
public async Task <int> UpdateAsync(int id, InstructionModel model) { await InstructionLogic.UpdateModelAsync(id, model); return(await DbContext.SaveChangesAsync()); }
public InstructionExecutionContext(bool[] memory, int programCounter, InstructionModel instruction) { Memory = memory; ProgramCounter = programCounter; Instruction = instruction; }