Exemplo n.º 1
0
 @Override
 public Pointer apply(SmartList<Pointer> args) throws MintException {
   short i = 0;
   while (i < Short.MAX_VALUE) {
     try {
       HashMap<Integer, String> strs = Heap.strings;
       if (strs == null) {
         return EMPTY_LIST;
       }
       Table tbl = new Table();
       ArrayList<Integer> keys = new ArrayList<Integer>();
       Set<Integer> s = strs.keySet();
       for (int element : s) {
         keys.add(element);
       }
       s = null;
       for (int key : keys) {
         SmartList<Pointer> pair = new SmartList<Pointer>();
         pair.add(new Pointer(Constants.INT_TYPE, key));
         pair.add(Heap.allocateString(strs.get(key)));
         tbl.addBinding(pair);
       }
       return Heap.allocateTable(tbl);
     } catch (Throwable t) {
     }
     ++i;
   }
   try {
     return Heap.allocateString(Heap.strings.toString());
   } catch (Throwable t) {
     return ChangeString.ERROR;
   }
 }
Exemplo n.º 2
0
 @Override
 public Pointer apply(SmartList<Pointer> args) {
   String[] split;
   if (args.isEmpty() || args.get(0).type == Constants.NULL_TYPE) {
     split = str.split(" ");
   } else {
     String regex = PointerTools.dereferenceString(args.get(0));
     split = str.split(regex);
   }
   SmartList<Pointer> list = new SmartList<Pointer>();
   for (String eachString : split) {
     list.add(Heap.allocateString(eachString));
   }
   return Heap.allocateList(list);
 }
Exemplo n.º 3
0
 @Override
 public Pointer apply(SmartList<Pointer> args) throws MintException {
   Pointer arg0 = args.get(0);
   Pointer arg1 = args.get(1);
   if (arg0.type == Constants.BIG_INT_TYPE && arg1.type == Constants.BIG_INT_TYPE) {
     BigInteger op0 = PointerTools.dereferenceBigInt(arg0);
     BigInteger op1 = PointerTools.dereferenceBigInt(arg1);
     return Heap.allocateBigInt(op0.or(op1));
   }
   Integer operand0 = PointerTools.dereferenceInt(arg0);
   Integer operand1 = PointerTools.dereferenceInt(arg1);
   if (operand0 == null || operand1 == null) {
     throw new MintException("Bitwise or can only be applied to " + "integers.");
   }
   return Heap.allocateInt(operand0 | operand1);
 }