Package org.erlide.util.erlang

Examples of org.erlide.util.erlang.Bindings


    @SuppressWarnings("boxing")
    public FunctionRef[] functionUse(final String mod, final String fun, final int arity) {
        try {
            final OtpErlangObject r = backend.call(ERLIDE_XREF, "function_use", "aai",
                    mod, fun, arity);
            final Bindings bind = OtpErlang.match("{ok, L}", r);
            if (bind == null) {
                return new FunctionRef[0];
            }
            final OtpErlangList l = (OtpErlangList) bind.get("L");
            final List<FunctionRef> result = new ArrayList<FunctionRef>();
            for (final OtpErlangObject e : l) {
                result.add(new FunctionRef(e));
            }
            return result.toArray(new FunctionRef[result.size()]);
View Full Code Here


    }

    static final List<OtpErlangObject> NO_STACK = new ArrayList<OtpErlangObject>();

    private FailReason parseReason(final OtpErlangObject reason) {
        Bindings b;
        try {
            b = OtpErlang.match("{Cause, Stack}", reason);
            if (b == null) {
                return new FailReason("internal error: " + reason.toString(), NO_STACK);
            }
            final Collection<OtpErlangObject> stack = b.getList("Stack");
            return new FailReason(b.get("Cause").toString(), stack);
        } catch (final TermParserException e) {
            ErlLogger.warn(e);
        } catch (final OtpErlangException e) {
            ErlLogger.warn(e);
        }
View Full Code Here

  public static boolean match(final String template, final OtpErlangObject data, final Function1<? super Bindings, ? extends Boolean> callback) {
    Boolean _xtrycatchfinallyexpression = null;
    try {
      Boolean _xblockexpression = null;
      {
        final Bindings b = OtpErlang.match(template, data);
        boolean _tripleEquals = (b == null);
        if (_tripleEquals) {
          return false;
        }
        _xblockexpression = callback.apply(b);
View Full Code Here

      final Function1<OtpErlangObject, OtpErlangObject> _function = new Function1<OtpErlangObject, OtpErlangObject>() {
        public OtpErlangObject apply(final OtpErlangObject it) {
          try {
            OtpErlangObject _xblockexpression = null;
            {
              final Bindings b = OtpErlang.match("{project,N,Msg,error}", it);
              boolean _tripleEquals = (b == null);
              if (_tripleEquals) {
                return it;
              }
              final long n = b.getLong("N");
              final String msg = b.getString("Msg");
              final String HDR = "Failed to extract name from ";
              boolean _startsWith = msg.startsWith(HDR);
              boolean _not = (!_startsWith);
              if (_not) {
                return it;
View Full Code Here

        }

        @Override
        public String toString() {
            try {
                final Bindings b = OtpErlang.match("{M:a, F:a, A}", item);
                m = b.getQuotedAtom("M");
                f = b.getQuotedAtom("F");
                a = b.get("A");
                final String aa = a.toString();
                final String args;
                if (a instanceof OtpErlangLong) {
                    args = " / " + aa;
                } else {
View Full Code Here

        return result;
      }
      final Procedure1<OtpErlangObject> _function = new Procedure1<OtpErlangObject>() {
        public void apply(final OtpErlangObject erl_opts) {
          try {
            final Bindings bindings = OtpErlang.match("{erl_opts,Opts}", erl_opts);
            boolean _tripleNotEquals = (bindings != null);
            if (_tripleNotEquals) {
              final Collection<OtpErlangObject> opts = bindings.getList("Opts");
              boolean _tripleNotEquals_1 = (opts != null);
              if (_tripleNotEquals_1) {
                final Procedure1<OtpErlangObject> _function = new Procedure1<OtpErlangObject>() {
                  public void apply(final OtpErlangObject opt) {
                    try {
                      final Bindings b = OtpErlang.match("{Tag,Arg}", opt);
                      boolean _tripleNotEquals = (b != null);
                      if (_tripleNotEquals) {
                        RebarConfigurationSerializer.this.parseOption(result, b);
                      }
                    } catch (Throwable _e) {
View Full Code Here

        return result;
      }
      final Procedure1<OtpErlangObject> _function = new Procedure1<OtpErlangObject>() {
        public void apply(final OtpErlangObject erl_opts) {
          try {
            final Bindings bindings = OtpErlang.match("{Src,Opts}", erl_opts);
            boolean _tripleNotEquals = (bindings != null);
            if (_tripleNotEquals) {
              final String src = bindings.getAtom("Src");
              String _xifexpression = null;
              boolean _contains = src.contains("/");
              if (_contains) {
                String[] _split = src.split("/");
                _xifexpression = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(_split)));
              } else {
                _xifexpression = "src";
              }
              final String path = _xifexpression;
              Collection<IPath> _sourceDirs = result.getSourceDirs();
              final ArrayList<IPath> sd = new ArrayList<IPath>(_sourceDirs);
              Path _path = new Path(path);
              sd.add(_path);
              result.setSourceDirs(sd);
              final Collection<OtpErlangObject> opts = bindings.getList("Opts");
              boolean _tripleNotEquals_1 = (opts != null);
              if (_tripleNotEquals_1) {
                final Procedure1<OtpErlangObject> _function = new Procedure1<OtpErlangObject>() {
                  public void apply(final OtpErlangObject opt) {
                    try {
                      final Bindings b = OtpErlang.match("{Tag,Arg}", opt);
                      boolean _tripleNotEquals = (b != null);
                      if (_tripleNotEquals) {
                        EmakeConfigurationSerializer.this.parseOption(b, result);
                      }
                    } catch (Throwable _e) {
View Full Code Here

            final String value, final int stackFrameNo, final OtpErlangPid meta) {
        try {
            final OtpErlangObject res = backend.call(ERLIDE_DEBUG, "set_variable_value",
                    "ssix", name, value, stackFrameNo + 1, meta);
            try {
                final Bindings bind = OtpErlang.match("{eval_rsp, {'EXIT', Val}}", res);
                if (bind == null) {
                    return null;
                }
                final String err = bind.getAsString("Val");
                return err;
            } catch (final TermParserException e1) {
            }
            return null;
        } catch (final RpcException e) {
View Full Code Here

    public static boolean isEmbedded(final IOtpRpc backend) {
        try {
            final OtpErlangObject r = backend.call(CODE, "ensure_loaded", "a",
                    "funny_module_name_that_nobody_would_use");
            final Bindings b = OtpErlang.match("{error, What}", r);
            if (b.getAtom("What").equals("embedded")) {
                return true;
            }
        } catch (final Exception e) {
            // ignore errors
        }
View Full Code Here

    @SuppressWarnings("boxing")
    public FunctionRef(final OtpErlangObject e) {
        if (e instanceof OtpErlangTuple) {
            final OtpErlangTuple t = (OtpErlangTuple) e;
            try {
                final Bindings bb = OtpErlang.match("{M:a, F:a, A:i}", t);
                final String m = bb.getAs("M", String.class);
                final String f = bb.getAs("F", String.class);
                final int a = bb.getAs("A", Integer.class);

                module = m;
                function = f;
                arity = a;
            } catch (final Exception e2) {
View Full Code Here

TOP

Related Classes of org.erlide.util.erlang.Bindings

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.