Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangAtom


  @Override
  public BeamFileData load(File file) throws IOException {

    sendGEN(conn, "beam_loader", new OtpErlangTuple(
        new OtpErlangObject[] {
              new OtpErlangAtom("disasm"),
              new OtpErlangString(file.getAbsolutePath()) }));

    try {
      OtpErlangObject reply = conn.receiveRPC();
View Full Code Here


  @Override
  public BeamFileData load(byte[] data) throws IOException {

    sendGEN(conn, "beam_loader", new OtpErlangTuple(
        new OtpErlangObject[] {
              new OtpErlangAtom("disasm"),
              new OtpErlangBinary(data) }));

    try {
      OtpErlangObject reply = conn.receiveRPC();
View Full Code Here

    /* {self, { call, Mod, Fun, Args, user}} */

    reply[0] = self.pid();
    reply[1] = self.createRef();
   
    gen[0] = new OtpErlangAtom("$gen_call");
    gen[1] = new OtpErlangTuple(reply);
    gen[2] = request;

    conn.send(server, new OtpErlangTuple(gen));
  }
View Full Code Here

     */
    public TracePattern(final boolean setXMatchSpec) {
        matchSpec = new MatchSpec();
        if (setXMatchSpec) {
            matchSpec.setFunctionString("x");
            matchSpec.setMsObject(new OtpErlangAtom("x"));
        }
    }
View Full Code Here

            final List<OtpErlangAtom> nodeAtoms = new ArrayList<OtpErlangAtom>();

            for (final Object o : TraceBackend.getInstance().getTracedNodesArray()) {
                final TracedNode tracedNode = (TracedNode) o;
                if (tracedNode.isEnabled()) {
                    nodeAtoms.add(new OtpErlangAtom(tracedNode.getNodeName()));
                }
            }

            final OtpErlangList nodesList = new OtpErlangList(
                    nodeAtoms.toArray(new OtpErlangAtom[nodeAtoms.size()]));
View Full Code Here

                ((MatchSpec) getValue()).setMsObject(null);
                return null;
            } else if ("x".equals(newText)) {
                // shortcut for matching exceptions and return values
                ((MatchSpec) getValue()).setFunctionString("x");
                ((MatchSpec) getValue()).setMsObject(new OtpErlangAtom("x"));
                return null;
            }
            try {

                final IOtpRpc backend = getBackend();
                final OtpErlangTuple tuple = (OtpErlangTuple) backend.call(
                        Constants.ERLANG_HELPER_MODULE, Constants.FUN_STR2MS, "s",
                        new OtpErlangString(newText));
                if (((OtpErlangAtom) tuple.elementAt(0)).atomValue().equals("ok")) {
                    // correct match spec - update
                    ((MatchSpec) getValue()).setFunctionString(newText);
                    ((MatchSpec) getValue()).setMsObject(tuple.elementAt(1));
                    return null;
                }
                // incorrect match spec
                final OtpErlangAtom errorType = (OtpErlangAtom) tuple.elementAt(1);
                if (errorType.atomValue().equals("standard_info")) {
                    final OtpErlangTuple errorTuple = (OtpErlangTuple) tuple.elementAt(2);
                    final StringBuilder builder = new StringBuilder("Line ");
                    builder.append(errorTuple.elementAt(0)).append(": ");
                    final OtpErlangList errorList = (OtpErlangList) errorTuple
                            .elementAt(2);
                    builder.append(((OtpErlangString) errorList.elementAt(0))
                            .stringValue());
                    if (errorList.elementAt(1) instanceof OtpErlangString) {
                        builder.append(((OtpErlangString) errorList.elementAt(1))
                                .stringValue());
                    }
                    return builder.toString();
                } else if (errorType.atomValue().equals("not_fun")) {
                    return "Given expression is not a function";
                } else if (errorType.atomValue().equals("unbound_var")) {
                    final StringBuilder builder = new StringBuilder("Unbound variable: ");
                    builder.append(tuple.elementAt(2));
                    return builder.toString();
                } else {
                    return tuple.elementAt(2).toString();
View Full Code Here

     * @return <code>true</code> if it is last message, <code>false</code>
     *         otherwise
     */
    public boolean isTracingFinished(final OtpErlangObject message) {
        if (message instanceof OtpErlangAtom) {
            final OtpErlangAtom atom = (OtpErlangAtom) message;
            if (atom.atomValue().equals(ATOM_STOP_TRACING)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

     */
    public OtpErlangObject getErrorReson(final OtpErlangObject message) {
        if (message instanceof OtpErlangTuple) {
            final OtpErlangTuple tuple = (OtpErlangTuple) message;
            if (tuple.elementAt(0) instanceof OtpErlangAtom) {
                final OtpErlangAtom atom = (OtpErlangAtom) tuple.elementAt(0);
                if (atom.atomValue().equals(ATOM_ERROR_LOADING)) {
                    return tuple.elementAt(1);
                }
            }
        }
        return null;
View Full Code Here

                final String atomValue = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
                if (atomValue.equals(ATOM_TRACE_TS)) {
                    // trace data: {trace_ts, Data}

                    final OtpErlangAtom traceType = (OtpErlangAtom) tuple
                            .elementAt(INDEX_TRACE_TYPE);
                    lastTraceDate = readDateTuple((OtpErlangTuple) tuple.elementAt(tuple
                            .arity() - 1));

                    switch (TraceType.valueOf(traceType.atomValue().toUpperCase())) {
                    case CALL:
                        return processCallTrace("Call", tuple);
                    case EXCEPTION_FROM:
                        return processExceptionFrom("Exception", tuple);
                    case EXIT:
View Full Code Here

    private ITreeNode createFunctionNode(final String label,
            final OtpErlangObject erlangObject) {
        final ITreeNode node = new TreeNode();
        if (erlangObject instanceof OtpErlangTuple) {
            final OtpErlangTuple functionTuple = (OtpErlangTuple) erlangObject;
            final OtpErlangAtom moduleName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_MODULE);
            final OtpErlangAtom functionName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_NAME);

            // args or arity node
            final TreeNode argsNode = new TreeNode();
            argsNode.setImage(Activator.getImage(Images.INFO_NODE));
            final OtpErlangObject arityOrArgs = functionTuple
                    .elementAt(INDEX_FUNCTION_ARGS);
            int arityValue = -1;
            if (arityOrArgs instanceof OtpErlangList) {
                // last element is a list of arguments
                final OtpErlangList arguments = (OtpErlangList) arityOrArgs;
                final StringBuilder builder = new StringBuilder("arguments: ");
                for (int i = 1; i < arguments.arity(); i++) {
                    builder.append(arguments.elementAt(i)).append(", ");
                }
                arityValue = arguments.arity() - 1;
                argsNode.setLabel(builder.substring(0, builder.length() - 2));
            } else {
                // last element is arity
                try {
                    if (functionTuple.elementAt(INDEX_FUNCTION_ARGS) instanceof OtpErlangInt) {
                        arityValue = ((OtpErlangInt) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).intValue();
                    } else {
                        arityValue = (int) ((OtpErlangLong) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).longValue();
                    }
                    argsNode.setLabel("arity: " + arityValue);
                } catch (final OtpErlangRangeException e) {
                    ErlLogger.error(e);
                }
            }

            // module name node
            final TreeNode moduleNameNode = new ModuleNode(moduleName.atomValue());
            moduleNameNode.setLabel("module: " + moduleName);

            // function name node
            final TreeNode functionNameNode = new FunctionNode(moduleName.atomValue(),
                    functionName.atomValue(), arityValue);
            functionNameNode.setLabel("function: " + functionName);

            node.addChildren(moduleNameNode, functionNameNode, argsNode);
            lastFunctionDescription = label + moduleName + ":" + functionName + "/"
                    + arityValue;
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangAtom

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.