示例#1
0
    public synchronized void fail() throws Fail {
      int err = GetLastError();
      Memory buffer = new Memory(2048);
      int res =
          FormatMessageW(
              FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
              null,
              err,
              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
              buffer,
              (int) buffer.size(),
              null);

      log =
          log
              && log(
                  1,
                  "fail() %s, Windows GetLastError()= %d, %s\n",
                  lineno(1),
                  err,
                  buffer.getString(0, true));

      // FIXME here convert from Windows error code to 'posix' error code

      Fail f = new Fail();
      throw f;
    }
  @Override
  public boolean onOptionsItemSelected(MenuItem menuItem) {

    switch (menuItem.getItemId()) {
      case R.id.menu_item_new_memory:
        Memory memory = new Memory();
        try {
          MemoryList.get(getActivity()).addMemory(memory);
        } catch (IOException e) {
          e.printStackTrace();
        } catch (JSONException e) {
          e.printStackTrace();
        }
        Intent i = new Intent(getActivity(), MemoryPagerActivity.class);
        i.putExtra(MemoryFragment.EXTRA_MEMORY_ID, memory.getMemoryId());
        startActivityForResult(i, MEMORY_RETURN);
        Toast.makeText(getActivity(), "New Memory is created", Toast.LENGTH_LONG).show();
        return true;

      case R.id.menu_item_show_subtitle:
        if (getActivity().getActionBar().getSubtitle() == null) {
          getActivity().getActionBar().setSubtitle(R.string.Subtitle);
          menuItem.setTitle(R.string.hide_subtitle);
          subtitleVisability = true;
        } else {
          getActivity().getActionBar().setSubtitle(null);
          menuItem.setTitle(R.string.show_subtitle);
          subtitleVisability = false;
        }
        return true;
      default:
        return super.onOptionsItemSelected(menuItem);
    }
  }
示例#3
0
  public Instructions(String codeIn, int add) {

    String code = codeIn.trim();
    code = code.replaceAll("\\s+", "");
    System.out.println("Code In:\n" + code);

    int len = code.length();
    int chunkLength = 2; // the length of each chunk of code
    for (int i = 0; i < len; i += chunkLength) {
      String chunk = code.substring(i, Math.min(len, i + chunkLength));
      System.out.println("code chunk no. " + (i / 2) + " " + chunk);
      // opCode(chunk); //TODO - need to call this from the memory class I
      // think

      MemoryArray MA = new MemoryArray();
      Memory mem = new Memory();

      // set the memory address and OpCode
      mem.setAddress(add);
      mem.setOpCode(Integer.parseInt(chunk, 16));

      // add the memory object to the memory array
      MA.addMemoryObjects(add, mem);
      // System.out.println("New memory = " + MA.getAddress() + " "
      // + MA.getOpCode());
      add++;
    }
  }
 @Override
 public void setBits(long offsetBytes, byte bitMask) {
   assertBounds(offsetBytes, BYTE_SIZE, capacityBytes_);
   long address = getAddress(offsetBytes);
   byte value = mem_.getByte(address);
   mem_.putByte(address, (byte) (value | bitMask));
 }
示例#5
0
  @Test
  public void testSaveThenReadFromMemory_MemoryNotFullWhenSavingAndNotEmptyWhenReading()
      throws Exception {
    memory.saveInMemory(operationToSave);
    String readedOperation = memory.readLastFromMemory();

    assertEquals(operationToSave, readedOperation);
  }
 // 代表启动计算机
 public void start() {
   memory.read();
   memory.write();
   cpu.read();
   cpu.write();
   disk.read();
   disk.write();
 }
示例#7
0
  private void miss(Scenario scene) {
    List<Word> concepts = null;
    if (memory.getConcepts().containsKey(scene.getContet()))
      concepts = memory.getConcepts().get(scene.getContet());

    if (concepts != null) {
      scene.addMeans(concepts);
    }
  }
  @Override
  @ForceInline
  public void write(long offsetInRDO, @NotNull ByteBuffer bytes, int offset, int length) {
    if (bytes.isDirect()) {
      memory.copyMemory(((DirectBuffer) bytes).address(), address + translate(offsetInRDO), length);

    } else {
      memory.copyMemory(bytes.array(), offset, address + translate(offsetInRDO), length);
    }
  }
 @NotNull
 private static NativeBytesStore<Void> of(long capacity, boolean zeroOut, boolean elastic)
     throws IllegalArgumentException {
   Memory memory = OS.memory();
   long address = memory.allocate(capacity);
   if (zeroOut || capacity < MEMORY_MAPPED_SIZE) {
     memory.setMemory(address, capacity, (byte) 0);
     memory.storeFence();
   }
   Deallocator deallocator = new Deallocator(address, capacity);
   return new NativeBytesStore<>(address, capacity, deallocator, elastic);
 }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {

    // Memory m = (Memory) (getListAdapter()).getItem(position);
    Memory m = ((MemoryAdapter) getListAdapter()).getItem(position);
    // Log.d(TAG, m.getMemoryTitle() + " is selected ");

    // Intent i = new Intent(getActivity(),MemoryActivity.class);

    Intent i = new Intent(getActivity(), MemoryPagerActivity.class);
    i.putExtra(MemoryFragment.EXTRA_MEMORY_ID, m.getMemoryId());
    startActivityForResult(i, MEMORY_RETURN);
    Toast.makeText(getActivity(), m.getMemoryTitle() + " is selected ", Toast.LENGTH_LONG).show();
  }
示例#11
0
 public void testLongStringGeneration() {
   StringBuilder buf = new StringBuilder();
   final int MAX = Platform.isWindowsCE() ? 200000 : 2000000;
   for (int i = 0; i < MAX; i++) {
     buf.append('a');
   }
   String s1 = buf.toString();
   Memory m = new Memory((MAX + 1) * Native.WCHAR_SIZE);
   m.setWideString(0, s1);
   assertEquals("Missing terminator after write", 0, m.getChar(MAX * Native.WCHAR_SIZE));
   String s2 = m.getWideString(0);
   assertEquals("Wrong string read length", s1.length(), s2.length());
   assertEquals("Improper wide string read", s1, s2);
 }
示例#12
0
 @NotNull
 @Override
 @ForceInline
 public NativeBytesStore<Underlying> writeOrderedInt(long offset, int i) {
   memory.writeOrderedInt(address + translate(offset), i);
   return this;
 }
示例#13
0
  @Override
  @ForceInline
  public byte readByte(long offset) {
    if (Jvm.isDebug()) checkReleased();

    return memory.readByte(address + translate(offset));
  }
示例#14
0
 @Override
 public void putBooleanArray(long offsetBytes, boolean[] srcArray, int srcOffset, int length) {
   long copyBytes = length << BOOLEAN_SHIFT;
   assertBounds(srcOffset, length, srcArray.length);
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   mem_.putBooleanArray(getAddress(offsetBytes), srcArray, srcOffset, length);
 }
示例#15
0
 @NotNull
 @Override
 @ForceInline
 public NativeBytesStore<Underlying> writeVolatileShort(long offset, short i16) {
   memory.writeVolatileShort(address + translate(offset), i16);
   return this;
 }
示例#16
0
  /**
   * @param line - linha com a definicao
   * @param level - nivel do symbolo
   */
  public SymbolArray(String line, Memory mem, int level) throws LanguageException {
    super(Symbol.ARRAY, true);
    this.level = level;
    IteratorArray it = new IteratorArray(line);
    String mod = Symbol.getDefAlter(line);
    String type = Symbol.getDefType(line);
    String nameVar = Symbol.getDefName(it.getNext());

    // nome da variavel
    name = nameVar + getOriginalDims(line);

    int dimension = Integer.valueOf(it.getNext()); // numero de dimensoes

    data = new Vector<SymbolData>(dimension);

    nameVar = nameVar + it.getUnprocessed();

    nameVar = mod + " " + type + " " + nameVar;
    for (int i = 0; i < dimension; i++) {
      SymbolData var =
          Memory.makeNewSymbol(nameVar + Symbol.iniArray + i + Symbol.finArray, mem, level);
      var.normalizeName();
      data.add(var);
    }

    //        objectValue = data;

    // constructor
  }
示例#17
0
 @Override
 public void getDoubleArray(long offsetBytes, double[] dstArray, int dstOffset, int length) {
   long copyBytes = length << DOUBLE_SHIFT;
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   assertBounds(dstOffset, length, dstArray.length);
   mem_.getDoubleArray(getAddress(offsetBytes), dstArray, dstOffset, length);
 }
示例#18
0
 @Override
 public void getShortArray(long offsetBytes, short[] dstArray, int dstOffset, int length) {
   long copyBytes = length << SHORT_SHIFT;
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   assertBounds(dstOffset, length, dstArray.length);
   mem_.getShortArray(getAddress(offsetBytes), dstArray, dstOffset, length);
 }
示例#19
0
 @Override
 public void putShortArray(long offsetBytes, short[] srcArray, int srcOffset, int length) {
   long copyBytes = length << SHORT_SHIFT;
   assertBounds(srcOffset, length, srcArray.length);
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   mem_.putShortArray(getAddress(offsetBytes), srcArray, srcOffset, length);
 }
示例#20
0
 @Override
 public void putDoubleArray(long offsetBytes, double[] srcArray, int srcOffset, int length) {
   long copyBytes = length << DOUBLE_SHIFT;
   assertBounds(srcOffset, length, srcArray.length);
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   mem_.putDoubleArray(getAddress(offsetBytes), srcArray, srcOffset, length);
 }
示例#21
0
 @NotNull
 @Override
 @ForceInline
 public NativeBytesStore<Underlying> writeFloat(long offset, float f) {
   memory.writeFloat(address + translate(offset), f);
   return this;
 }
示例#22
0
文件: swi.java 项目: hetau/cycle
  /**
   * Performs one operation cycle of the instruction in the pipeline stage. The pipeline stage is
   * define by the parameter stage.<br>
   * In Fireworks Three Stage Pipeline processor the instruction only operates in the execute
   * pipeline stage. Because of that the parameter stage in practice is never used.
   *
   * @param stage the pipeline stage where the instruction is operating.
   *     <p>1 - fetch stage.<br>
   *     2 - decode stage.<br>
   *     3 - execute stage.
   * @return the cpu status after the instruction operates the cycle.
   * @see system.cpu.Instruction#Stage(int)
   */
  public final int Stage(int stage) {
    int address;
    int aux_d;
    int aux_a;
    int status;
    int esr;

    if (cycles < latency) {
      cycles++;
      return cpu_status.STALL;
    }
    aux_d = cpu.getGeneral(rD);
    aux_a = cpu.getGeneral(rA);
    imm = cpu.signExtendedIMM(imm);
    address = aux_a + imm;
    status = memory.putWord(address, aux_d);
    switch (status) {
      case Mem_Status.ACCESS:
        return cpu_status.MEM_ACCESS;
      case Mem_Status.READY:
        cycles = 1;
        return cpu_status.NORMAL;
      case Mem_Status.UNALIGNED:
        esr = 0xc00 | (rD << 5);
        cpu.putESR(esr);
        cpu.putEAR(address);
        cycles = 1;
        return cpu_status.MEM_UNALIGNED;
      case Mem_Status.MAPPED:
        cpu.putEAR(address);
        cycles = 1;
        return cpu_status.MEM_MAPPED;
    }
    return cpu_status.NORMAL;
  }
示例#23
0
 @NotNull
 @Override
 @ForceInline
 public NativeBytesStore<Underlying> writeDouble(long offset, double d) {
   memory.writeDouble(address + translate(offset), d);
   return this;
 }
示例#24
0
文件: Computer.java 项目: yrmt/JvavSE
 public void startup() {
   System.out.println("start the computer!");
   cpu.startup();
   memory.startup();
   disk.startup();
   System.out.println("start computer finished!");
 }
示例#25
0
 @NotNull
 @Override
 @ForceInline
 public NativeBytesStore<Underlying> writeVolatileLong(long offset, long i64) {
   memory.writeVolatileLong(address + translate(offset), i64);
   return this;
 }
示例#26
0
文件: Computer.java 项目: yrmt/JvavSE
 public void shutdown() {
   System.out.println("begin to close computer!");
   disk.shutdowm();
   memory.shutdowm();
   cpu.shutdown();
   System.out.println("GG");
 }
示例#27
0
  public long appendUTF(long pos, char[] chars, int offset, int length) {
    long address = this.address + translate(0);
    Memory memory = this.memory;
    int i;
    ascii:
    {
      for (i = 0; i < length; i++) {
        char c = chars[offset + i];
        if (c > 0x007F) break ascii;
        memory.writeByte(address + pos++, (byte) c);
      }

      return pos;
    }
    return appendUTF0(pos, chars, offset, length, i);
  }
示例#28
0
 @Override
 public void getBooleanArray(long offsetBytes, boolean[] dstArray, int dstOffset, int length) {
   long copyBytes = length << BOOLEAN_SHIFT;
   assertBounds(offsetBytes, copyBytes, capacityBytes_);
   assertBounds(dstOffset, length, dstArray.length);
   mem_.getBooleanArray(getAddress(offsetBytes), dstArray, dstOffset, length);
 }
示例#29
0
  @Override
  public OsStats osStats() {
    final long uptime = -1L;
    final double systemLoadAverage =
        ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
    final double[] loadAverage =
        systemLoadAverage < 0.0d ? new double[0] : new double[] {systemLoadAverage};
    final Processor processor =
        Processor.create(
            "Unknown",
            "Unknown",
            -1,
            -1,
            -1,
            -1,
            -1L,
            (short) -1,
            (short) -1,
            (short) -1,
            (short) -1);
    final Memory memory = Memory.create(-1L, -1L, (short) -1, -1L, (short) -1, -1L, -1L);
    final Swap swap = Swap.create(-1L, -1L, -1L);

    return OsStats.create(loadAverage, uptime, processor, memory, swap);
  }
示例#30
0
 @Override
 public boolean isAnyBitsSet(long offsetBytes, byte bitMask) {
   assertBounds(offsetBytes, BYTE_SIZE, capacityBytes_);
   long address = getAddress(offsetBytes);
   int value = mem_.getByte(address) & bitMask & 0XFF;
   return value != 0;
 }