Package erjang

Examples of erjang.EObject


    try {
      rest = charlist.collectCharList(collector, rest);
    } catch (CharCollector.InvalidElementException e) {
      throw ERT.badarg(charlist, encodingSpec);
    } catch (CharCollector.CollectingException e) {
      EObject data = output_converter.convert(out);
      return ETuple.make(ERROR_ATOM, data, e.restOfInput);
    } catch (IOException e) {
      throw new Error(e); // Not supposed to happen.
    }

    try {
      collector.end();

      if (rest != ERT.NIL) {
        return ETuple.make(INCOMPLETE_ATOM, 
                   output_converter.convert(out),
                   ErlConvert.iolist_to_binary(rest.reverse()));
      }
     
    } catch (CharCollector.PartialDecodingException e) {
      EObject data = output_converter.convert(out);
      return ETuple.make(INCOMPLETE_ATOM, data);
    } catch (IOException e) {
      throw new Error(e); // Not supposed to happen.
    }
View Full Code Here


      @Deprecated
      private Type[] parmTypes(TypeMap current, ESeq args) {
        ArrayList<Type> res = new ArrayList<Type>();

        while (args != ERT.NIL) {
          EObject arg = args.head();
          res.add(getType(current, arg));
          args = args.tail();
        }

        return res.toArray(new Type[res.size()]);
View Full Code Here

      }

      private TypeMap setType(TypeMap current, EObject dd, Type type) {
        ETuple dst = dd.testTuple();

        EObject key = dst.elm(1);
        EObject value = dst.elm(2);
        if (key == X_ATOM) {
          current = current.setx(value.asInt(),
              type == Type.DOUBLE_TYPE ? EDOUBLE_TYPE : type,
                     FV.this);
        } else if (key == Y_ATOM) {
          current = current.sety(value.asInt(),
              type == Type.DOUBLE_TYPE ? EDOUBLE_TYPE : type);
        } else if (key == FR_ATOM) {
          current = current.setf(value.asInt(), type);
        } else {
          throw new Error("unknown " + dst);
        }

        return current;
View Full Code Here

             
              EFun job = EFunCG.get_fun_with_handler("erlang", "apply", 0, new EFunHandler() {
                @Override
                public EObject invoke(EProc proc, EObject[] _) throws Pausable {

                  EObject aa = JavaObject.box(proc, args);
                  EObject at = JavaObject.box(proc, method.getParameterTypes());

                  EObject[] call_args = new EObject[] {
                    EAtom.intern(method.getName()), at, aa
                  };

                  EObject result = ifun.invoke(proc, call_args);

                  Object jresult = JavaObject.unbox(proc,
                      method.getReturnType(),
                      result);
View Full Code Here

      protected Object run(IPersistentMap map) {
        int count = 0;
        for (ESeq seq = values; !seq.isNil(); seq = seq.tail()) {
          ETuple value = seq.head().testTuple();
          if (value == null) throw ERT.badarg(values);
          EObject key = get_key(value);
          IPersistentCollection c =
            (IPersistentCollection) map.valAt(key, empty());

          // Insert element - noting whether the map grows
          int sizeBefore = c.count();
View Full Code Here

  protected void insert_one(final ETuple value) {
    in_tx(new WithMap<Object>() {
      @Override
      protected Object run(IPersistentMap map) {
        IPersistentCollection empty = empty();
        EObject key = get_key(value);
        IPersistentCollection c =
          (IPersistentCollection) map.valAt(key, empty);

        // Insert element - noting whether the map grows
        int sizeBefore = c.count();
View Full Code Here

  @SuppressWarnings("rawtypes")
  @Override
  public ESeq match(EPattern matcher) {   
   
    EObject key = matcher.getKey(keypos1);
    if (key == null) {
     
      // oops, .. tablescan
      ESeq res = ERT.NIL;
     
View Full Code Here

  @SuppressWarnings("rawtypes")
  @Override
  public ESeq match_object(final EPattern matcher) {   
   
    EObject key = matcher.getKey(keypos1);
    if (key == null) {
     
      // oops, .. tablescan
      ESeq res = ERT.NIL;
     
View Full Code Here

  @Override
  protected void delete_object(final ETuple obj) {
    in_tx(new WithMap<Object>() {
      @Override
      protected Object run(IPersistentMap map) {
        EObject key = get_key(obj);
        IPersistentCollection empty = empty();
        IPersistentCollection c =
          (IPersistentCollection) map.valAt(key, empty);
       
        if (c == null || c.count()==0)
          return null;
       
        IPersistentCollection out = empty();
        int deleted = 0;
       
        for (ISeq s = c.seq(); s != null; s = s.next()) {
          EObject val = (EObject) s.first();
          if (val == null) break;
         
          if (! obj.equalsExactly(val)) {
            out = out.cons(val);
          } else {
View Full Code Here

  @Override
  public EObject select(final EMatchSpec matcher, int limit) {
   
    IPersistentMap map = deref();
   
    EObject key = matcher.getTupleKey(keypos1);
   
    if (key == null) {
      EBagCont cont0 = new EBagCont(matcher, map.seq(), null, limit);
      return cont0.select();
     
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.