package jetbrains.mps.ide.dataFlow.presentation; /*Generated by MPS */ import jetbrains.mps.lang.dataFlow.framework.instructions.Instruction; import org.jetbrains.mps.openapi.model.SNodeReference; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.smodel.SNodePointer; import jetbrains.mps.lang.dataFlow.framework.instructions.IfJumpInstruction; import jetbrains.mps.lang.dataFlow.framework.instructions.JumpInstruction; import jetbrains.mps.lang.dataFlow.framework.instructions.WriteInstruction; import jetbrains.mps.lang.dataFlow.framework.instructions.ReadInstruction; import jetbrains.mps.lang.dataFlow.framework.instructions.RetInstruction; public class GraphCreator implements IGraphCreator<InstructionWrapper> { public GraphCreator() { } @Override public IBlock createBlock(InstructionWrapper wrapper, int x, int y, int width, int height) { Instruction instruction = wrapper.getInstruction(); SNodeReference pointer; if (instruction.getSource() instanceof SNode) { pointer = new SNodePointer(((SNode) instruction.getSource())); } else { pointer = null; } String caption = instruction.toString(); String rule = instruction.getRuleReference(); if (instruction instanceof IfJumpInstruction) { return new AltBlock(x, y, width, height, pointer, caption, rule); } if (instruction instanceof JumpInstruction) { return new JumpBlock(x, y, width, height, pointer, caption, rule); } if (instruction instanceof WriteInstruction) { return new WriteBlock(x, y, width, height, pointer, caption, rule); } if (instruction instanceof ReadInstruction) { return new ReadBlock(x, y, width, height, pointer, caption, rule); } if (instruction instanceof RetInstruction) { return new ReturnBlock(x, y, width, height, pointer, caption, rule); } return new SimpleBlock(x, y, width, height, pointer, caption, rule); } }