Package erjang

Examples of erjang.ETuple


  /** return list of matching members' vars */
  ESeq match_vars(ESeq out, ISeq in) {

    while (in != null) {
      ETuple elm = (ETuple) in.first();
      if (elm == null)
        break;

      EMatchContext res = new EMatchContext(out_vars, elm);
      if (matcher.match(elm, res)) {
View Full Code Here


        return vm.value;
      }
    } else if (matcher instanceof ValuePattern) {
      ValuePattern vp = (ValuePattern) matcher;
      if (vp.value instanceof ETuple) {
        ETuple et = (ETuple) vp.value;
        if (keypos1 < 1 || keypos1 > et.arity())
          return null;
        return et.elm(keypos1);
      }
    }
    return null;
  }
View Full Code Here

        elems[idx1 - 1] = tup.elm(idx1).compileMatch(out);
      }
    }

    public boolean match(EObject elm, EMatchContext res) {
      ETuple tup;
      if ((tup = elm.testTuple()) == null)
        return false;
      return match(tup, res);
    }
View Full Code Here

    }
    return res;
  }

  public EObject makeTuple() {
    ETuple res = ETuple.make(varnames.length);
    for (int i = 0; i < varnames.length; i++) {
      res.set(i+1, vars.get(varnames[i]));
    }
    return res;
  }
View Full Code Here

    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");
View Full Code Here

                                            // TODO: Implement LINE instruction!
                                            continue next_insn;
                                        }

          default: {
            ETuple insn = insn_.toSymbolicTuple();
            throw new Error("unhandled: " + insn + "::" + current);
          }
          }//switch
        }
View Full Code Here

      public void visitInsn(Insn insn) {
        insns.add(insn);
      }

      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) {
View Full Code Here

        }

        return arr;
      }

      ETuple tup;
      if ((tup = val.testTuple()) != null) {
        int length = tup.arity();
        Class<?> componentType = type.getComponentType();
        Object arr = Array.newInstance(componentType, length);

        for (int index = 0; index < length; index++) {
          Object value = JavaObject.unbox(self, componentType, tup
              .elm(index + 1));
          Array.set(arr, index, value);
        }

        return arr;
View Full Code Here

      } catch (InvocationTargetException e) {
        Throwable te = e.getTargetException();
        if (te instanceof ErlangException) {
          throw (ErlangException) te;
        } else {
          ETuple reason = ETuple.make(EAtom.intern(te.getClass()
              .getName()), EString.fromString(te.getMessage()));
          throw new ErlangError(reason, args);
        }
      }
View Full Code Here

      } catch (InvocationTargetException e) {
        Throwable te = e.getTargetException();
        if (te instanceof ErlangException) {
          throw (ErlangException) te;
        } else {
          ETuple reason = ETuple.make(EAtom.intern(te.getClass()
              .getName()), EString.fromString(te.getMessage()));
          throw new ErlangError(reason, args);
        }
      }
View Full Code Here

TOP

Related Classes of erjang.ETuple

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.