View Javadoc

1   package com.tapina.robe.swi.clib.stdlib;
2   
3   import com.tapina.robe.runtime.Environment;
4   import com.tapina.robe.swi.clib.Stub;
5   
6   /***
7    * This function converts the start of the string pointed to by a1 to an int. If the string cannot be converted, the
8    * behaviour is undefined.
9    * Returns: The converted value.
10   */
11  public class AToI extends Stub {
12      public void executeStub(Environment environment) {
13          final int[] R = environment.getCpu().R;
14          final String s = environment.getMemoryMap().getString0(R[0]);
15          try {
16              R[0] = Integer.parseInt(s);
17          } catch (NumberFormatException e) {
18              log.warning("Unable to convert '" + s + "' in atoi()");
19              R[0] = 0;
20          }
21      }
22  }