Пример #1
0
 public static Term execute(Process proc, Module m, Instruction i, List params) {
   Tuple tuple = i.arg(0).toArg(proc).toTuple();
   List dst = i.arg(2).toList();
   while (dst.length() > 0) {
     Integer arity = dst.head().toInteger();
     dst = dst.tail();
     Term lbl = dst.head();
     if (tuple.arity() == arity.toInt()) {
       return lbl;
     }
     dst = dst.tail();
   }
   return i.arg(1);
 }
Пример #2
0
 /**
  * Returns a port identifier as the result of opening a new Erlang port. A port can be seen as an
  * external Erlang process.
  *
  * <p>http://erlang.org/doc/man/erlang.html#open_port-2
  */
 public static PortID open_port_2(Tuple portName, List portSettings) {
   Atom name = portName.element(1).toAtom();
   if (spawn.equals(name)) {
     Term command = portName.element(2);
     return VirtualMachine.instance().spawn_port(command, portSettings);
   } else if (spawn_driver.equals(name)) {
     Term command = portName.element(2);
     return VirtualMachine.instance().spawn_driver_port(command, portSettings);
   } else if (spawn_executable.equals(name)) {
     Term fileName = portName.element(2);
     return VirtualMachine.instance().spawn_executable_port(fileName, portSettings);
   } else {
     throw Error.badarg;
   }
 }