Package erjang

Examples of erjang.EObject


      @Override
      protected Integer run(IPersistentMap map) {
        ESeq vals = ERT.NIL;
        int initial_count = sizeRef.get();
       
        EObject key = matcher.getTupleKey(keypos1);
       
        if (key == null) {
          vals = matcher.matching_values_bag(vals, (Map<EObject, IPersistentCollection>) map);
        } else {
          IPersistentCollection coll = (IPersistentCollection) map.valAt(key);
View Full Code Here


  }

  @BIF
  static public EObject run(EObject subj, EObject re, EObject opts) {
    try {
      EObject res = run2(subj, re, opts);
      //System.out.println("re:run("+subj+", "+re+", "+opts+") => "+res);
      return res;
    } catch (RuntimeException e) {
      //System.out.println("re:run("+subj+", "+re+", "+opts+") => "+e);
      // e.printStackTrace();
View Full Code Here

    if (re instanceof ECompiledRE) {
      regex = (ECompiledRE) re;

    } else {
      ETuple2 res = compile(re, opts);
      EObject val = res.elem2;
      if (res.elem1 == ERT.am_ok && ( val instanceof ECompiledRE)) {
        regex = (ECompiledRE) val;
      } else {
        return val;
      }
    }

    ESeq o = opts.testSeq();
    Options o2;
   
    if (o.isNil()) {
      o2 = regex.options;
    } else {
      o2 = regex.options.re_init(o);
     
      if (o2 == null) {
        throw ERT.badarg(subj, re, opts);
      }
    }
   
    String subject = regex.options.decode(subj);
    if (subject == null) {
      throw ERT.badarg(subj, re, opts);
    }
   
    if (o2.offset > subject.length() || o2.offset < 0) {
      throw ERT.badarg(subj, re, opts);
    }
   
    Matcher matcher = regex.patt.matcher(subject.substring(o2.offset ));
       
    if (o2.global) {
     
      ESeq result = ERT.NIL;
     
      while (matcher.find()) {
        MatchResult mr = matcher.toMatchResult();
     
        ESeq list;
        if (o2.capture_spec == am_all) {
          ESeq l = ERT.NIL;
          for (int i = mr.groupCount(); i >= 0; i--) {
            l = l.cons( capture (subject, mr, i, o2) );
          }
         
          result = result.cons(l);
        } 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?
               }
             } else {
View Full Code Here

        assert seq_has_more(coll_seq);
       
        ETuple candidate = (ETuple) coll_seq.first();
        coll_seq = coll_seq.next();
       
        EObject res;
        if ((res = matcher.match(candidate)) != null) {
          count += 1;
          vals = vals.cons(res);
        }
      }
View Full Code Here

  public String toString() {return toSymbolic().toString();}
  public EObject toSymbolic() {
      return opcode.symbol;
  }
  public final ETuple toSymbolicTuple() {
    EObject symInsn0 = toSymbolic();
    ETuple symInsn = (symInsn0 instanceof ETuple)?
      ((ETuple)symInsn0) : ETuple.make(symInsn0);
    return symInsn;
  }
View Full Code Here

    if (cr == null || node == null || cr.value > 3 || !is_node_name_atom(node)) {
      if (log.isLoggable(Level.FINE)) log.fine("cr="+cr+"; node="+node+"; is_name="+is_node_name_atom(node));
      throw ERT.badarg(arg_node, arg_creation);
    }

    EObject net_kernel = ERT.whereis(am_net_kernel);   
    EInternalPID nk = net_kernel.testInternalPID();
    if (nk == null) {
      throw new ErlangError(EAtom.intern("no_net_kernel"));
    }
   
    nk.set_dist_entry(this_dist_entry);
View Full Code Here

    EAtom access = am_protected;
    int keypos = 1;
    boolean write_concurrency = false;
    boolean read_concurrency = false;
    EInternalPID heir_pid = null;
    EObject heir_data = null;
    boolean is_named = false;

    for (; !opts.isNil(); opts = opts.tail()) {
      EObject option = opts.head();

      EAtom atom;
      ETuple2 t2;
      ETuple3 t3;
      if ((atom = option.testAtom()) != null) {
        if (atom == am_bag || atom == am_duplicate_bag
            || atom == am_set || atom == am_ordered_set) {
          type = atom;
          continue;
        } else if (atom == am_public || atom == am_private
View Full Code Here

      }
    } else {
      throw ERT.badarg(nameOrTid, matchSpec);
    }
   
    EObject res = table.select(spec, -1);

    ETuple2 tup;
    if (res == am_$end_of_table) {
      return ERT.NIL;
    } else if ((tup=ETuple2.cast(res)) != null
View Full Code Here

      throw ERT.badarg(list, matchSpec, tail_arg);
    }

    while (!input.isNil()) {
     
      EObject candidate = input.head();
      EObject o = spec.match(candidate);
      if (o != null) {
        res = res.cons(o);
      }
     
      input = input.tail();
View Full Code Here

    ETable table;
    if ((table = get_table(nameOrTid)) == null) {
      return ERT.am_undefined;
    }

    EObject info = table.info(item);

    if (info == null)
      throw ERT.badarg(nameOrTid, item);
    else
      return info;
View Full Code Here

TOP

Related Classes of erjang.EObject

Copyright © 2018 www.massapicom. 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.