コード例 #1
0
  private void processSetSystemPropertiesCmd(DataInputStream params, IOTACommandHelper helper)
      throws IOException {
    int dataSize = helper.getDataInputStream().readInt();
    ByteArrayOutputStream baos = new ByteArrayOutputStream(dataSize);
    helper.receiveFile(dataSize, baos);
    Properties newPersistentProperties = new Properties();
    newPersistentProperties.load(new ByteArrayInputStream(baos.toByteArray()));

    Properties oldPersistentProperties = spot.getPersistentProperties();

    // store new properties in flash
    spot.storeProperties(newPersistentProperties);

    // remove deleted properties from current isolate
    Enumeration oldKeys = oldPersistentProperties.keys();
    while (oldKeys.hasMoreElements()) {
      String oldKey = (String) oldKeys.nextElement();
      if (!newPersistentProperties.containsKey(oldKey)) {
        VM.setProperty(oldKey, null);
      }
    }

    // store new and modified properties in current isolate
    Enumeration newKeys = newPersistentProperties.keys();
    while (newKeys.hasMoreElements()) {
      String newKey = (String) newKeys.nextElement();
      VM.setProperty(newKey, newPersistentProperties.getProperty(newKey));
    }

    helper.sendPrompt();
  }
コード例 #2
0
ファイル: Run.java プロジェクト: johangas/moped
 public static void main(String[] args) {
   VM.println("Run.main()");
   Run autoBrake = new Run(args);
   autoBrake.init();
   autoBrake.doFunction();
   VM.println("Run-main done");
 }
コード例 #3
0
ファイル: Translator.java プロジェクト: johangas/moped
 public byte[] getResourceData(String name) {
   Assert.that(VM.isHosted() || VM.getCurrentIsolate().getLeafSuite() == suite);
   try {
     byte[] bytes = classPath.getBytes(name);
     ResourceFile resourceFile = new ResourceFile(name, bytes);
     suite.installResource(resourceFile);
     return bytes;
   } catch (IOException e) {
     return null;
   }
 }
コード例 #4
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * Get any error message provided by the platform (as in dlerror). If no error, then return null.
  *
  * <p>Note that calling this method clears the error state, so calling two times without calling
  * any other platform getFunction method (getInstance(), getFunction(),
  * getGlobalVariableAddress(), dispose()) will result in returning null.
  *
  * @return String (may be null)
  */
 public static String errorStr() {
   if (DEBUG) {
     VM.println("Calling DLERROR");
   }
   int result = VM.execSyncIO(ChannelConstants.DLERROR, 0, 0, 0, 0, 0, 0, null, null);
   Address r = Address.fromPrimitive(result);
   if (r.isZero()) {
     return null;
   } else {
     return Pointer.NativeUnsafeGetString(r);
   }
 }
コード例 #5
0
ファイル: Translator.java プロジェクト: johangas/moped
 /** {@inheritDoc} */
 public void load(Klass klass) {
   Assert.that(VM.isHosted() || VM.getCurrentIsolate().getLeafSuite() == suite);
   int state = klass.getState();
   if (state < Klass.STATE_LOADED) {
     if (klass.isArray()) {
       load(klass.getComponentType());
     } else {
       lastClassNameStack.push(klass.getName());
       ClassFile classFile = getClassFile(klass);
       load(classFile);
       lastClassNameStack.pop();
     }
   }
 }
コード例 #6
0
ファイル: GCFSocketsImpl.java プロジェクト: johangas/moped
 /** Read errno, try to clean up fd, and create exception. */
 private IOException newError(int fd, String msg) {
   if (DEBUG) {
     VM.print(msg);
     VM.print(": errno: ");
   }
   int err_code = LibCUtil.errno();
   if (DEBUG) {
     VM.print(err_code);
     VM.println();
   }
   sockets.shutdown(fd, 2);
   libc.close(fd);
   return new IOException(" errno: " + err_code + " on fd: " + fd + " during " + msg);
 }
コード例 #7
0
ファイル: MailboxAddress.java プロジェクト: johangas/moped
  /**
   * This method looks up a MailboxAddress that has been registered with the system, and implicitly
   * opens the connection to the remote Mailbox. It also opens the reply address for the remote
   * mailbox, so it may send responses back to this Isolate.
   *
   * @param name the name of the Mailbox to lookup.
   * @param replyMailbox the address of a local mailbox that the remote isolate can send replies to.
   * @return an open address to the remote mailbox named <code>name</code>.
   * @throws NoSuchMailboxException if there is no mailbox named <code>name</code>.
   */
  public static MailboxAddress lookupMailbox(String name, Mailbox replyMailbox)
      throws NoSuchMailboxException {
    Mailbox box = VM.lookupMailbox(name);

    if (box == null) {
      throw new NoSuchMailboxException(name);
    }

    MailboxAddress replyAddress = new MailboxAddress(replyMailbox);
    MailboxAddress startingAddress = new MailboxAddress(box);
    MailboxAddress finalAddress = box.callHandleOpen(startingAddress, replyAddress);

    if (finalAddress == null) {
      // something fell apart in callHandleOpen
      throw new NoSuchMailboxException(name);
    }

    // record the address of the remote mailbox with this isolate:
    finalAddress.recordAddress(Isolate.currentIsolate(), replyAddress);

    // also, tell the isolate containing the remote mailbox about the
    // reply address that it will use to send replies back to this isolate.
    replyAddress.recordAddress(box.getOwner(), finalAddress);

    return finalAddress;
  }
コード例 #8
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * Look up a native libray named "name". Load if not loaded. Name can be a path or a libray name.
  * The Library will be looked up in a platform-dependant manor.
  *
  * @param name short library name, full file name, or path to the library file
  * @return NativeLibrary
  */
 public static NativeLibrary getInstance(String name) {
   String nativeName = nativeLibraryName(name);
   Pointer name0 = Pointer.createStringBuffer(nativeName);
   if (DEBUG) {
     VM.print("Calling DLOPEN on ");
     VM.println(name);
   }
   int result =
       VM.execSyncIO(
           ChannelConstants.DLOPEN, name0.address().toUWord().toInt(), 0, 0, 0, 0, 0, null, null);
   Address r = Address.fromPrimitive(result);
   name0.free();
   if (r.isZero()) {
     throw new RuntimeException("Can't open library " + name + ". OS Error: " + errorStr());
   }
   return new NativeLibrary(name, r);
 }
コード例 #9
0
ファイル: Linker.java プロジェクト: rotemcg/moped
  public int getVirtualRPortId(int pportId) {
    // showtables();
    // VM.println("getVirtualRPortId " + pportId);

    Enumeration<Integer> keys = pportId2vrportId.keys();
    while (keys.hasMoreElements()) {
      Integer from = keys.nextElement();
      Integer to = pportId2vrportId.get(from);
      // VM.println(" link " + from + " -> " + to);
      if (from.intValue() == pportId) return to.intValue();
    }

    Integer p = pportId2vrportId.get(new Integer(pportId));
    VM.println("getVirtualRPortId -> " + p);
    VM.println("getVirtualRPortId -> val " + p.intValue());
    return p.intValue();
  }
コード例 #10
0
ファイル: Run.java プロジェクト: johangas/moped
  public void doFunction() {
    String data;

    VM.println("[Run is running] 2");

    speed = new PluginPPort(this, "sp");
    steering = new PluginPPort(this, "st");

    for (int j = 0; j < 1; j++) {
      try {
        Thread.sleep(2000);
        speed.write(0);
        steering.write(0);
        Thread.sleep(2000);

        speed.write(20);
        steering.write(0);
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        VM.println("Interrupted.");
      }
    }

    while (true) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        VM.println("Interrupted.");
      }

      try {
        // Object obj = ab.receive();
        Object obj = getval(ab);
        if (obj != null) {
          VM.println("ab returned an object");
          VM.println("ab returned an object: " + obj);

          String s = (String) obj;
          int x = Integer.parseInt(s);
          if (x < 150) {
            speed.write(0);
            steering.write(0);
          }
          if (x > 150) {
            speed.write(20);
            steering.write(0);
          }

        } else {
          speed.write(30);
          steering.write(0);
          VM.println("ab returned null");
        }

      } catch (Exception e) {
        e.printStackTrace();
        VM.println("Run: exception");
      }
    }
  }
コード例 #11
0
ファイル: Linker.java プロジェクト: rotemcg/moped
  public int getPluginRPortId(int pportId) {
    showtables();
    VM.println("getPluginRPortId " + pportId);
    // TODO: What is this while-loop for???
    Enumeration<Integer> keys = pportId2rportId.keys();
    while (keys.hasMoreElements()) {
      Integer from = keys.nextElement();
      Integer to = pportId2rportId.get(from);

      VM.println(" link " + from + " -> " + to);
      if (from.intValue() == pportId) return to.intValue();
    }

    Integer p = pportId2rportId.get(pportId);
    VM.println("getPluginRPortId -> " + p);
    VM.println("getPluginRPortId -> val " + p.intValue());
    return p;
  }
コード例 #12
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * Close the library, as in dlclose.
  *
  * @throws RuntimeException if dlcose fails
  */
 public void dispose() {
   if (closed || ptr.isZero()) {
     throw new RuntimeException("closed or RTLD_DEFAULT");
   }
   if (DEBUG) {
     VM.print("Calling DLCLOSE on ");
     VM.println(name);
   }
   Pointer name0 = Pointer.createStringBuffer(name);
   int result =
       VM.execSyncIO(
           ChannelConstants.DLCLOSE, ptr.toUWord().toInt(), 0, 0, 0, 0, 0, 0, null, null);
   name0.free();
   if (result != 0) {
     throw new RuntimeException("Error on dlclose: " + errorStr());
   }
   closed = true;
 }
コード例 #13
0
ファイル: Translator.java プロジェクト: johangas/moped
  /** {@inheritDoc} */
  public void close(int suiteType) throws NoClassDefFoundError {
    long time = 0;
    this.suiteType = suiteType;

    if (verbose()) {
      Tracer.trace("[Translator: computing closure...");
      time = System.currentTimeMillis();
    }

    computeClosure();

    if (translationStrategy == BY_SUITE || translationStrategy == BY_TRANSLATION) {
      if (verbose()) {
        time = System.currentTimeMillis() - time;
        Tracer.traceln(time + "ms.]");
        Tracer.trace("[Translator: whole-suite optimizing and inlining...");
        time = System.currentTimeMillis();
      }
      // bytecode optimizations and inlining go here

      if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
        dme = new DeadMethodEliminator(this);
        dme.computeMethodsUsed();
      }

      if (Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool()) {
        dce = new DeadClassEliminator(this);
        dce.computeClassesUsed();
      }

      if (verbose()) {
        time = System.currentTimeMillis() - time;
        Tracer.traceln(time + "ms.]");
        Tracer.trace("[Translator: phase2...");
        time = System.currentTimeMillis();
      }

      for (int cno = 0; cno < suite.getClassCount(); cno++) {
        Klass klass = suite.getKlass(cno);
        Assert.always(Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool() || (klass != null));
        if (klass != null) {
          convertPhase2(klass);
        }
      }
    }
    classFiles.clear();

    if (verbose()) {
      time = System.currentTimeMillis() - time;
      Tracer.traceln(time + "ms.]");

      if (VM.isVeryVerbose()) {
        InstructionEmitter.printUncalledNativeMethods();
      }
    }
    Assert.always(lastClassNameStack.empty());
  }
コード例 #14
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * Dynamically look up a native function address by name. Look up the symbol in the specified
  * library
  *
  * @param funcName
  * @return address of the function
  * @throws RuntimeException if there is no function by that name.
  */
 private Address getFunction0(String funcName) {
   Address result = getSymbolAddress(funcName);
   if (DEBUG) {
     VM.print("Function Lookup for ");
     VM.print(funcName);
     VM.print(" = ");
     VM.printAddress(result);
     VM.println();
   }
   if (result.isZero()) {
     if (Platform.getPlatform().isWindows()) {
       if (funcName.charAt(funcName.length() - 1) != 'A') {
         return getFunction0(funcName + 'A');
       }
     } else if (funcName.charAt(0) != '_') {
       return getFunction0("_" + funcName);
     }
     throw new RuntimeException(
         "Can't find native symbol " + funcName + ". OS Error: " + errorStr());
   }
   return result;
 }
コード例 #15
0
ファイル: Translator.java プロジェクト: johangas/moped
 public boolean processOption(String arg) {
   if (arg.startsWith("-")) {
     for (int i = 0; i < Arg.translatorArgs.length; i++) {
       Arg translatorArg = Arg.translatorArgs[i];
       String optionStr = translatorArg.getOptionName();
       if (arg.startsWith(optionStr)) {
         String val = arg.substring(optionStr.length()).toUpperCase();
         VM.setProperty(translatorArg.getPropertyName(), val);
         return true;
       }
     }
   }
   return false;
 }
コード例 #16
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * getFunction a symbol's address by name (warpper around dlsym)
  *
  * @param name
  * @return Address of symbol
  */
 private Address getSymbolAddress(String name) {
   if (closed) {
     throw new IllegalStateException("closed");
   }
   if (DEBUG) {
     VM.print("Calling DLSYM on ");
     VM.println(name);
   }
   Pointer name0 = Pointer.createStringBuffer(name);
   int result =
       VM.execSyncIO(
           ChannelConstants.DLSYM,
           ptr.toUWord().toInt(),
           name0.address().toUWord().toInt(),
           0,
           0,
           0,
           0,
           null,
           null);
   name0.free();
   return Address.fromPrimitive(result);
 }
コード例 #17
0
ファイル: Run.java プロジェクト: johangas/moped
 private Object getval(PluginRPort port) {
   WorkThread p = new WorkThread(ab);
   p.start();
   try {
     Thread.sleep(1000);
   } catch (InterruptedException e) {
     VM.println("Interrupted.");
   }
   Object o2 = p.obj;
   // VM.println("plupp " + o2);
   if (p.obj != null) {
     // p.stop();
   }
   return o2;
 }
コード例 #18
0
ファイル: Linker.java プロジェクト: rotemcg/moped
 public void link(LinkContextEntry entry) {
   int fromPortId = entry.getFromPortId();
   int toPortId = entry.getToPortId();
   int remotePortId = entry.getRemotePortId();
   if (remotePortId == Configuration.PPORT2VPORT) {
     // from PluginPort to VirtualPort
     VM.println("Linking " + fromPortId + " -> " + toPortId + " as P->V");
     pportId2vrportId.put(fromPortId, toPortId);
   } else if (remotePortId == Configuration.PPORT2PPORT) {
     // from PluginPort to PluginPort and they are in the same ECU
     VM.println("Linking " + fromPortId + " -> " + toPortId + " as P->P on the same ECU");
     pportId2rportId.put(fromPortId, toPortId);
   } else if (remotePortId == Configuration.VPORT2PPORT) {
     // from VirtualPPort to PluginRPort
     VM.println("Linking " + toPortId + " -> " + fromPortId + " as V->P");
     rportId2vpportId.put(toPortId, fromPortId);
   } else if (remotePortId > 0) {
     // from PluginPort to PluginPort but they are in different ECUs
     // In this case, remotePortId is just remote plug-in port ID
     pportId2rportId.put(fromPortId, remotePortId);
     // PV entry is also needed to register
     pportId2vrportId.put(fromPortId, toPortId);
   }
 }
コード例 #19
0
ファイル: Translator.java プロジェクト: johangas/moped
 /**
  * Generate squawk code for methods of <code>klass</code> when doing whole-suite translation
  * (inlining, etc.)
  *
  * @param klass the klass to generate code for
  */
 void convertPhase2(Klass klass) {
   Assert.that(translationStrategy != BY_METHOD);
   convert(klass);
   if (klass.getState() < Klass.STATE_CONVERTED) {
     if (!VM
         .isVerbose()) { // "squawk -verbose" will show the class names as it finishes loading
                         // them, which is progress enough
       traceProgress();
     }
     lastClassNameStack.push(klass.getName());
     ClassFile classFile = getClassFile(klass);
     classFile.convertPhase2(this, false);
     classFiles.remove(klass.getName());
     lastClassNameStack.pop();
   }
 }
コード例 #20
0
 private void processUndeployCmd(DataInputStream params, IOTACommandHelper helper)
     throws IOException {
   String suiteUri = params.readUTF();
   FlashFile suiteFile = new FlashFile(suiteUri);
   if (suiteFile.exists()) {
     if (helper.isSuiteInUse(suiteUri)) {
       if (suiteUri.equals(Isolate.currentIsolate().getParentSuiteSourceURI())) {
         helper.makeObsolete(suiteUri);
       } else {
         helper.sendErrorDetails("Attempt to undeploy suite that is in use");
         return;
       }
     } else {
       VM.unregisterSuite(suiteUri);
       suiteFile.delete();
     }
   } else {
     helper.sendErrorDetails("Attempt to undeploy unknown suite: " + suiteUri);
     return;
   }
   helper.sendPrompt();
 }
コード例 #21
0
ファイル: NativeLibrary.java プロジェクト: johangas/moped
 /**
  * Dynamically look up a native variable by name.
  *
  * <p>Look up the symbol in the default list of loaded libraries.
  *
  * @param varName
  * @param size the size of the variable in bytes
  * @return a Pointer that can be used to get/set the variable
  * @throws RuntimeException if there is no function by that name.
  */
 public VarPointer getGlobalVariableAddress(String varName, int size) {
   Address result = getSymbolAddress(varName);
   if (DEBUG) {
     VM.print("Var Lookup for ");
     VM.print(varName);
     VM.print(", size: ");
     VM.print(size);
     VM.print(" returned ");
     VM.printAddress(result);
     VM.println();
   }
   if (result.isZero()) {
     if (varName.charAt(0) != '_') {
       return getGlobalVariableAddress("_" + varName, size);
     }
     throw new RuntimeException(
         "Can't find native symbol " + varName + ". OS Error: " + errorStr());
   }
   return new VarPointer(varName, result, size);
 }
コード例 #22
0
ファイル: Object.java プロジェクト: CARV-ICS-FORTH/disquawk
 public Object() {
   hashCode = (((VM.getIsland() << 3) | VM.getCore()) << 16) | VM.getNextHashcode();
 }
コード例 #23
0
ファイル: Object.java プロジェクト: CARV-ICS-FORTH/disquawk
 /**
  * Creates and returns a copy of this object. The precise meaning of "copy" may depend on the
  * class of the object. The general intent is that, for any object <tt>x</tt>, the expression:
  *
  * <blockquote>
  *
  * <pre>
  * x.clone() != x</pre>
  *
  * </blockquote>
  *
  * will be true, and that the expression:
  *
  * <blockquote>
  *
  * <pre>
  * x.clone().getClass() == x.getClass()</pre>
  *
  * </blockquote>
  *
  * will be <tt>true</tt>, but these are not absolute requirements. While it is typically the case
  * that:
  *
  * <blockquote>
  *
  * <pre>
  * x.clone().equals(x)</pre>
  *
  * </blockquote>
  *
  * will be <tt>true</tt>, this is not an absolute requirement.
  *
  * <p>By convention, the returned object should be obtained by calling <tt>super.clone</tt>. If a
  * class and all of its superclasses (except <tt>Object</tt>) obey this convention, it will be the
  * case that <tt>x.clone().getClass() == x.getClass()</tt>.
  *
  * <p>By convention, the object returned by this method should be independent of this object
  * (which is being cloned). To achieve this independence, it may be necessary to modify one or
  * more fields of the object returned by <tt>super.clone</tt> before returning it. Typically, this
  * means copying any mutable objects that comprise the internal "deep structure" of the object
  * being cloned and replacing the references to these objects with references to the copies. If a
  * class contains only primitive fields or references to immutable objects, then it is usually the
  * case that no fields in the object returned by <tt>super.clone</tt> need to be modified.
  *
  * <p>The method <tt>clone</tt> for class <tt>Object</tt> performs a specific cloning operation.
  * First, if the class of this object does not implement the interface <tt>Cloneable</tt>, then a
  * <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays are considered to implement
  * the interface <tt>Cloneable</tt>. Otherwise, this method creates a new instance of the class of
  * this object and initializes all its fields with exactly the contents of the corresponding
  * fields of this object, as if by assignment; the contents of the fields are not themselves
  * cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy"
  * operation.
  *
  * <p>The class <tt>Object</tt> does not itself implement the interface <tt>Cloneable</tt>, so
  * calling the <tt>clone</tt> method on an object whose class is <tt>Object</tt> will result in
  * throwing an exception at run time.
  *
  * @return a clone of this instance.
  * @exception CloneNotSupportedException if the object's class does not support the <code>
  *     Cloneable</code> interface. Subclasses that override the <code>clone</code> method can also
  *     throw this exception to indicate that an instance cannot be cloned.
  * @see java.lang.Cloneable
  */
 protected Object clone() throws CloneNotSupportedException {
   return VM.shallowCopy(this);
 }
コード例 #24
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the trigonometric cosine of an angle. Special case:
  *
  * <ul>
  *   <li>If the argument is NaN or an infinity, then the result is NaN.
  * </ul>
  *
  * @param a an angle, in radians.
  * @return the cosine of the argument.
  * @since CLDC 1.1
  */
 public static double cos(double a) {
   return VM.math(MathOpcodes.COS, a, 0);
 }
コード例 #25
0
ファイル: Set.java プロジェクト: CARV-ICS-FORTH/disquawk
  public void run() {

    long start, end;

    // Start timer
    start = System.currentTimeMillis();

    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);
    myint.set(50);

    end = System.currentTimeMillis();

    System.out.println(
        "W contention on atomic "
            + (end - start)
            + " ms BID: "
            + VM.getIsland()
            + " CID: "
            + VM.getCore());
  }
コード例 #26
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the trigonometric sine of an angle. Special cases:
  *
  * <ul>
  *   <li>If the argument is NaN or an infinity, then the result is NaN.
  *   <li>If the argument is positive zero, then the result is positive zero; if the argument is
  *       negative zero, then the result is negative zero.
  * </ul>
  *
  * @param a an angle, in radians.
  * @return the sine of the argument.
  * @since CLDC 1.1
  */
 public static double sin(double a) {
   return VM.math(MathOpcodes.SIN, a, 0);
 }
コード例 #27
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the largest (closest to positive infinity) <code>double</code> value that is not
  * greater than the argument and is equal to a mathematical integer. Special cases:
  *
  * <ul>
  *   <li>If the argument value is already equal to a mathematical integer, then the result is the
  *       same as the argument.
  *   <li>If the argument is NaN or an infinity or positive zero or negative zero, then the result
  *       is the same as the argument.
  * </ul>
  *
  * @param a a <code>double</code> value.
  *     <[email protected]  the value &lfloor;&nbsp;<code>a</code>&nbsp;&rfloor;.-->
  * @return the largest (closest to positive infinity) <code>double</code> value that is not
  *     greater than the argument and is equal to a mathematical integer.
  * @since CLDC 1.1
  */
 public static double floor(double a) {
   return VM.math(MathOpcodes.FLOOR, a, 0);
 }
コード例 #28
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the smallest (closest to negative infinity) <code>double</code> value that is not less
  * than the argument and is equal to a mathematical integer. Special cases:
  *
  * <ul>
  *   <li>If the argument value is already equal to a mathematical integer, then the result is the
  *       same as the argument.
  *   <li>If the argument is NaN or an infinity or positive zero or negative zero, then the result
  *       is the same as the argument.
  *   <li>If the argument value is less than zero but greater than -1.0, then the result is
  *       negative zero.
  * </ul>
  *
  * Note that the value of <code>Math.ceil(x)</code> is exactly the value of <code>-Math.floor(-x)
  * </code>.
  *
  * @param a a <code>double</code> value.
  *     <[email protected]  the value &lceil;&nbsp;<code>a</code>&nbsp;&rceil;.-->
  * @return the smallest (closest to negative infinity) <code>double</code> value that is not less
  *     than the argument and is equal to a mathematical integer.
  * @since CLDC 1.1
  */
 public static double ceil(double a) {
   return VM.math(MathOpcodes.CEIL, a, 0);
 }
コード例 #29
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the correctly rounded positive square root of a <code>double</code> value. Special
  * cases:
  *
  * <ul>
  *   <li>If the argument is NaN or less than zero, then the result is NaN.
  *   <li>If the argument is positive infinity, then the result is positive infinity.
  *   <li>If the argument is positive zero or negative zero, then the result is the same as the
  *       argument.
  * </ul>
  *
  * @param a a <code>double</code> value.
  * @return the positive square root of <code>a</code>. If the argument is NaN or less than zero,
  *     the result is NaN.
  * @since CLDC 1.1
  */
 public static double sqrt(double a) {
   return VM.math(MathOpcodes.SQRT, a, 0);
 }
コード例 #30
0
ファイル: Math.java プロジェクト: johangas/moped
 /**
  * Returns the trigonometric tangent of an angle. Special cases:
  *
  * <ul>
  *   <li>If the argument is NaN or an infinity, then the result is NaN.
  *   <li>If the argument is positive zero, then the result is positive zero; if the argument is
  *       negative zero, then the result is negative zero
  * </ul>
  *
  * @param a an angle, in radians.
  * @return the tangent of the argument.
  * @since CLDC 1.1
  */
 public static double tan(double a) {
   return VM.math(MathOpcodes.TAN, a, 0);
 }