示例#1
0
  @Specialization
  public ErlTuple makeTuple(long num, Object defaultElement, ErlList list) {

    if (num < 0 || num > Integer.MAX_VALUE) {
      throw ErlControlException.makeBadarg();
    }

    Object[] arr = new Object[(int) num];
    for (int i = 0; i < (int) num; ++i) {
      arr[i] = defaultElement;
    }

    ErlList tail = list;
    while (ErlList.NIL != tail) {

      Object h = tail.getHead();

      if (h instanceof ErlTuple) {

        ErlTuple init = (ErlTuple) h;

        if (2 == init.getSize()) {

          final int idx = ErlContext.decodeInt(init.getElement(1)) - 1;

          if (0 <= idx && idx < arr.length) {
            arr[idx] = init.getElement(2);
          } else {
            throw ErlControlException.makeBadarg();
          }
        } else {
          throw ErlControlException.makeBadarg();
        }
      } else {
        throw ErlControlException.makeBadarg();
      }

      Object t = tail.getTail();

      if (t instanceof ErlList) {
        tail = (ErlList) t;
      } else {
        throw ErlControlException.makeBadarg();
      }
    }

    return ErlTuple.fromArray(arr);
  }
示例#2
0
 @Specialization
 public double atan2(Object arg1, Object arg2) {
   return Math.atan2(ErlContext.toDouble(arg1), ErlContext.toDouble(arg2));
 }
示例#3
0
  @Specialization
  public ErlTuple makeTuple(Object arg1, Object arg2, Object arg3) {

    return makeTuple(ErlContext.decodeInt(arg1), arg2, ErlList.fromObject(arg3));
  }
示例#4
0
 @Specialization
 public boolean exit(ErlPort port, Object reason) {
   ErlContext.notImplemented();
   throw ErlControlException.makeBadarg();
 }