JVVM.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="jvvm">
  3. <source-code class="source-code"></source-code>
  4. <j-v-m-code v-if="state.currentFrame" class="j-v-m-code" :code="state.currentFrame.code"></j-v-m-code>
  5. <j-frame class="current-frame" name="current frame" :frame="state.currentFrame"></j-frame>
  6. <j-frame class="optional-frame" name="optional frame" :frame="state.optionalNextFrame"></j-frame>
  7. <memory v-if="state.memory" class="memory">
  8. <memory-object :key="name" :object="value" v-for="(value, name) in state.memory.objects" class="object"></memory-object>
  9. </memory>
  10. <div class="actions">
  11. <v-btn class="mx-2" fab dark small color="#5a6a7a" @click="goPreFrame">
  12. <v-icon dark>mdi-arrow-left</v-icon>
  13. </v-btn>
  14. <v-btn class="mx-2" fab dark small color="#5a6a7a" @click="goNextFrame">
  15. <v-icon dark>mdi-arrow-right</v-icon>
  16. </v-btn>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import JVMCode from '@/components/JVMCode'
  22. import SourceCode from '@/components/SourceCode'
  23. import JFrame from '@/components/JFrame'
  24. import Memory from '@/components/Memory'
  25. import MemoryObject from '@/components/MemoryObject'
  26. export default {
  27. name: 'JVVM',
  28. components: {
  29. MemoryObject,
  30. Memory,
  31. JFrame,
  32. SourceCode,
  33. JVMCode
  34. },
  35. props: {
  36. state: {
  37. default: () => ({ currentFrame: { code: [] }, optionalNextFrame: {}, memory: { objects: [] } }),
  38. type: Object
  39. },
  40. currentStateIndex: {
  41. default: 0,
  42. type: Number
  43. },
  44. totalStateLength: {
  45. default: 0,
  46. type: Number
  47. }
  48. },
  49. methods: {
  50. goNextFrame () {
  51. this.$emit('onNextFrame')
  52. },
  53. goPreFrame () {
  54. this.$emit('onPreFrame')
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .actions {
  61. position: fixed;
  62. right: 12px;
  63. bottom: 24px;
  64. }
  65. .jvvm {
  66. display: grid;
  67. grid-gap: 24px;
  68. }
  69. @media (min-width: 720px) {
  70. .source-code {
  71. grid-area: source;
  72. max-height: calc(100vh - 90px);
  73. overflow: auto;
  74. }
  75. .j-v-m-code {
  76. grid-area: jvm-code;
  77. max-height: calc(100vh - 90px);
  78. overflow: auto;
  79. }
  80. .current-frame {
  81. grid-area: current-frame;
  82. min-height: calc(50vh - 70px);
  83. overflow: auto;
  84. }
  85. .optional-frame {
  86. grid-area: optional-frame;
  87. min-height: calc(50vh - 70px);
  88. overflow: auto;
  89. }
  90. .memory {
  91. grid-area: memory;
  92. max-height: calc(50vh - 44px);
  93. overflow: auto;
  94. }
  95. .jvvm {
  96. display: grid;
  97. position: relative;
  98. grid-gap: 24px;
  99. grid-template-columns: 1.3fr 1.3fr 1fr 1fr;
  100. grid-template-areas: 'source jvm-code current-frame optional-frame' 'source jvm-code memory memory' 'source jvm-code memory memory';
  101. }
  102. .actions {
  103. position: absolute;
  104. left: 12px;
  105. bottom: 24px;
  106. }
  107. }
  108. </style>