Examples of EAtom


Examples of erjang.EAtom

  }

  @BIF
  public static EObject spawn(EProc proc, EObject mod, EObject fun, EObject args) {
   
    EAtom m = mod.testAtom();
    EAtom f = fun.testAtom();
    ESeq  a = args.testSeq();
   
    if (m==null||f==null||a==null)
      throw ERT.badarg(mod, fun, args);
   
View Full Code Here

Examples of erjang.EAtom

      }
      return ref;
    }

    // case 2: object is a name
    EAtom name;
    if (h == null && (name=object.testAtom()) != null) {
      ERef ref = ERT.getLocalNode().createRef();
      boolean success = false;
     
      object = new ETuple2(name, ErlDist.node());
     
      if ((h = ERT.whereis(name).testHandle()) != null)
      {  
        success = self.monitor(h, object, ref);
     
     
      if (!success) {
        self.mbox_send(ETuple.make(ERT.am_DOWN, ref, am_process, object, ERT.am_noproc));
      }

      return ref;
    }

    // case 3: object is {name, node}
    ETuple tup;
    EAtom node;
    if ((tup=object.testTuple()) != null
      && tup.arity()==2
      && (name=tup.elm(1).testAtom()) != null
      && (node=tup.elm(2).testAtom()) != null)
    {
View Full Code Here

Examples of erjang.EAtom

      return ERT.FALSE;
    }
   
    EHandle h;
    ETuple tup;
    EAtom name;
    EAtom node;
    if ((h=found.testHandle()) != null) {
      h.remove_monitor(self.self_handle(), r, flush);
    } else if ((tup=found.testTuple()) != null
          && tup.arity()==2
          && (name=tup.elm(1).testAtom()) != null
View Full Code Here

Examples of erjang.EAtom

  }
 
  @BIF
  static EAtom module_loaded(EObject mod) {
    EAtom m;
    if ((m=mod.testAtom()) == null) throw ERT.badarg(mod);
    return EModuleManager.module_loaded(m) ? ERT.TRUE : ERT.FALSE;
  }
View Full Code Here

Examples of erjang.EAtom

  }
 
  @BIF
  public static EAtom check_process_code(EObject pid_arg, EObject mod_arg) {
    EPID pid = pid_arg.testPID();
    EAtom mod = mod_arg.testAtom();
   
    if (pid == null || mod == null) { throw ERT.badarg(pid_arg, mod_arg); }
   
    log.log(Level.FINE, "check_process_code not implemented (" + pid + ", " + mod + ")");
 
View Full Code Here

Examples of erjang.EAtom

  }
 
  @BIF
  public static EObject hibernate(EProc self, EObject a1, EObject a2, EObject a3) {
   
    EAtom m = a1.testAtom();
    EAtom f = a2.testAtom();
    ESeq  a = a3.testSeq();
   
    if (m == null || f == null || a == null) {
      throw ERT.badarg(a1, a2, a3);
    }
View Full Code Here

Examples of erjang.EAtom

            break;
          }

          case fnegate:
            Insn.LSD insn = (Insn.LSD)insn_;
            EAtom name = opcode.symbol;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            Arg[] in = new Arg[] {src_arg(insn_idx, insn.src)};
            Type[] inTypes = new Type[] {in[0].type};
            Arg out = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(), inTypes,
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }
         
          case fconv:
          case fmove:
          case move: {
            Insn.SD insn = (Insn.SD)insn_;
            Arg src  = src_arg(insn_idx, insn.src);
            Arg dest = dest_arg(insn_idx, insn.dest);

            if (insns.size() > insn_idx+1) {
            Insn next_insn = insns.get(insn_idx+1);
            if (next_insn.opcode() == BeamOpcode.K_return) {
              vis.visitInsn(BeamOpcode.K_return, src);
              insn_idx += 1;
              break;
            }
            }
           
            if (dest.kind != Kind.F) {
              if (src.kind == Kind.F) {
                dest = new Arg(dest, EDOUBLE_TYPE);
              } else {
                dest = new Arg(dest, src.type);
              }
            } else {
              // arg2.kind == F
            }

            vis.visitInsn(opcode, src, dest);
            break;
          }

          case put_string: {
            Insn.ByD insn = (Insn.ByD)insn_;
            Arg src  = src_arg(insn_idx, insn.bin);
            Arg dest = dest_arg(insn_idx, insn.dest);
//             Arg arg1 = decode_arg(insn_idx, insn.elm(3));
//             Arg arg2 = decode_out_arg(insn_idx, insn.elm(4));
            dest = new Arg(dest, ESEQ_TYPE);
            vis.visitInsn(BeamOpcode.move, src, dest);
            break;
          }

          case fadd:
          case fsub:
          case fmul:
          case fdiv:
          {
            Insn.LSSD insn = (Insn.LSSD)insn_;
            EAtom name = opcode.symbol;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            Arg[] in = new Arg[] {src_arg(insn_idx, insn.src1),
                        src_arg(insn_idx, insn.src2)};
            Type[] inTypes = new Type[] {in[0].type,
                           in[1].type};
            Arg out = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(), inTypes,
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }

          case bif0:
          case bif1:
          case bif2:
          {
            Insn.Bif insn = (Insn.Bif)insn_;
            EAtom name = insn.ext_fun.fun;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            SourceOperand[] srcs = insn.args;
            Arg[] in = src_args(insn_idx, srcs);
            Arg out  = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(),
                parmTypes(type_map, srcs),
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }

           case gc_bif1:
           case gc_bif2:
           case gc_bif3:
          {
            Insn.GcBif insn = (Insn.GcBif)insn_;
            EAtom name = insn.ext_fun.fun;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            SourceOperand[] srcs = insn.args;
            Arg[] in = src_args(insn_idx, srcs);
            Arg out  = dest_arg(insn_idx, insn.dest);

            // special case for X+1, 1+X, X-1.
            Int lop = null, rop = null;
            if (srcs.length==2
                && (((name==am_plus || name == am_minus) && (rop=srcs[1].testInt()) != null && rop.equals(1))
                 || (name==am_plus && (lop=srcs[0].testInt()) != null && lop.equals(1))))
            {
              if (name == am_plus) {
                Arg src = (lop == null) ? in[0] : in[1];
               
                vis.visitIncrement(src, out);
                break;
              } else if (name == am_minus) {
                Arg src = in[0];
                vis.visitDecrement(src, out);
                break;               
              }
            }
           
            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(),
                parmTypes(type_map, srcs),
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
View Full Code Here

Examples of erjang.EAtom

            continue next_insn;
          }

          case fnegate: {
            Insn.LSD insn = (Insn.LSD)insn_;
            EAtom name = insn.opcode().symbol;
            SourceOperand[] parms = new SourceOperand[] {
              insn.src
            };
            Type type = getBifResult("erlang", name.getName(),
                         parmTypes(current, parms), false);
            current = setType(current, insn.dest, type);

            continue next_insn;
          }
          case fadd:
          case fsub:
          case fmul:
          case fdiv:
          {
            Insn.LSSD insn = (Insn.LSSD) insn_;
            EAtom name = insn.opcode().symbol;
            SourceOperand[] parms = new SourceOperand[] {
              insn.src1, insn.src2
            };
            Type type = getBifResult("erlang", name.getName(),
                         parmTypes(current, parms), false);
            current = setType(current, insn.dest, type);

            continue next_insn;
          }

           case gc_bif1:
           case gc_bif2:
           case gc_bif3:
          {
            // {gc_bif,BifName,F,Live,[A1,A2?],Reg};

            Insn.GcBif insn = (Insn.GcBif) insn_;
            boolean is_guard = (insn.label.nr != 0);

            current = branch(current, insn.label, insn_idx);

            EAtom name = insn.ext_fun.fun;
            SourceOperand[] parms = insn.argList();

            Type type = getBifResult("erlang", name.getName(),
                         parmTypes(current, parms), is_guard);

            current = setType(current, insn.dest, type);

            continue next_insn;
          }

          case bif0:
          case bif1:
          case bif2:
          {
            Insn.Bif insn = (Insn.Bif) insn_;
            current = branch(current, insn.label, insn_idx);

            EAtom name = insn.ext_fun.fun;
            SourceOperand[] parms = insn.argList();

            Type type = getBifResult("erlang", name.getName(),
                         parmTypes(current, parms), false);

            current = setType(current, insn.dest, type);

            continue next_insn;
View Full Code Here

Examples of erjang.EAtom

    return output_converter.convert(out);
  }

  public static Charset encodingSpecToCharset(EObject encoding) {
    EAtom ea;
    ETuple et;
    if ((ea = encoding.testAtom()) != null) {
      if (ea.equals(LATIN1_ATOM))
        return Charset.forName("ISO-8859-1");
      else if (ea.equals(UNICODE_ATOM) ||
           ea.equals(UTF8_ATOM))
        return Charset.forName("UTF-8");
      else if (ea.equals(UTF16_ATOM))
        return Charset.forName("UTF-16BE");
    } else if ((et = encoding.testTuple()) != null) {
      EAtom ea2;
      if ((ea  = et.elm(1).testAtom()) != null &&
        (ea2 = et.elm(21).testAtom()) != null) {
        if (ea.equals(UTF16_ATOM)){
          if (ea2.equals(LITTLE_ATOM))
            return Charset.forName("UTF-16LE");
          if (ea2.equals(BIG_ATOM))
            return Charset.forName("UTF-16BE");
        } else if (ea.equals(UTF32_ATOM)) {
          throw new NotImplemented();
        }
      }
View Full Code Here

Examples of erjang.EAtom

        } else if ((list = o2.capture_spec.testSeq()) != null) {
          ESeq l = ERT.NIL;
          while (!list.isNil()) {
            EObject group = list.head();
            ESmall num;
            EAtom nam;
            EString nam2;
            if ((num=group.testSmall()) != null)
            {
              l = l.cons( capture (subject, mr, num.value, o2 ));
            } else if ((nam=group.testAtom()) != null) {
              Integer groupNo = o2.named_groups.get(nam.getName());
              if (groupNo != null) {
                l = l.cons( capture (subject, mr, groupNo.intValue(), o2 ));
              }
            } else if ((nam2=group.testString()) != null) {
              Integer groupNo = o2.named_groups.get(nam2.stringValue());
              if (groupNo != null) {
                l = l.cons( capture (subject, mr, groupNo.intValue(), o2 ));
              }
            } else {
              throw new NotImplemented("named capture groups");
            }
            list = list.tail();
          }
          result = result.cons(l);

        } else {
          throw new NotImplemented("global and not all");
        }
      }
     
      if (result == ERT.NIL) {
        return am_nomatch;
      } else {
         return new ETuple2(am_match, result.reverse());
      }
     
    } else {
     
      if (matcher.find()) {
       
        if (o2.capture_spec  == am_none) {
          return am_match;
        }
       
        MatchResult mr = matcher.toMatchResult();
     
        int max = mr.groupCount();
        while( mr.start(max) == -1)
          max -= 1;
       
        ESeq il;
        if (o2.capture_spec == am_all) {
          ESeq l = ERT.NIL;
          for (int i = max; i >= 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
          return new ETuple2(am_match, l);
         
        } else if (o2.capture_spec == am_all_but_first) {
          ESeq l = ERT.NIL;
          for (int i = max; i > 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
          return new ETuple2(am_match, l);
         
        } else if (o2.capture_spec == am_first) {
          EObject l = capture (subject, mr, 0, o2);
          return new ETuple2(am_match, l);
         
        } else if ((il = o2.capture_spec.testSeq()) != null) {
         
          ESeq out = ERT.NIL;
         
           for (; !il.isNil(); il = il.tail()) {
             EObject what = il.head();
            ESmall idx = what.testSmall();
             EAtom nam;
            if (idx != null && mr.start(idx.value) != -1) {
               EObject val = capture (subject, mr, idx.value, o2);
               out = out.cons(val);
             } else if ((nam=what.testAtom())!=null) {
               Integer idx2 = o2.named_groups.get(nam.getName());
               if (idx2 != null) {
                   EObject val = capture (subject, mr, idx2, o2);
                   out = out.cons(val);
               } else {
                 // badarg?
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.