Package abstrasy.pcfx

Source Code of abstrasy.pcfx.PCFx_send

package abstrasy.pcfx;

import abstrasy.Interpreter;

import abstrasy.interpreter.InterpreterException;

import abstrasy.InterpreterSemaphore;
import abstrasy.Node;
import abstrasy.PCoder;

import abstrasy.interpreter.StdErrors;

/**
* Abstrasy Interpreter
*
* Copyright : Copyright (c) 2006-2012, Luc Bruninx.
*
* Concédée sous licence EUPL, version 1.1 uniquement (la «Licence»).
*
* Vous ne pouvez utiliser la présente oeuvre que conformément à la Licence.
* Vous pouvez obtenir une copie de la Licence à l’adresse suivante:
*
*   http://www.osor.eu/eupl
*
* Sauf obligation légale ou contractuelle écrite, le logiciel distribué sous
* la Licence est distribué "en l’état", SANS GARANTIES OU CONDITIONS QUELLES
* QU’ELLES SOIENT, expresses ou implicites.
*
* Consultez la Licence pour les autorisations et les restrictions
* linguistiques spécifiques relevant de la Licence.
*
*
* @author Luc Bruninx
* @version 1.0
*/

public class PCFx_send extends PCFx {

    public PCFx_send() {
    }

    /**
     * eval
     *
     * @param startAt Node
     * @return Node
     * @throws Exception
     * @todo Implémenter cette méthode abstrasy.PCFx
     */
    public Node eval(Node startAt) throws Exception {
        /*
         * (send <msg> to <acteur>) : Envoi <msg> à l'acteur <acteur>. Il s'agit d'un opérateur non bloquant.
         *                            Celui-ci peut donc être utilisé dans une section mutex ou atomic.
         *
         */
        startAt.isGoodArgsCnt(4);
        String target = startAt.getSubNode(3, Node.TYPE_STRING).getString();
        startAt.requirePCode(2, PCoder.PC_TO);
        Node msg = startAt.getSubNode(1, Node.VTYPE_VALUABLE);
        InterpreterSemaphore sema = Interpreter.getSemaphore();
        Interpreter amie = sema.getThread(target);
        if (amie != null) {
            /**
             * un acteur peut s'envoyer un message à lui-même...
             *
             */
            sema.send_MSG(amie, msg);
        }
        else {
            throw new InterpreterException(StdErrors.extend(StdErrors.Actor_not_found, target));
        }
        return null;
    }

}
TOP

Related Classes of abstrasy.pcfx.PCFx_send

TOP
Copyright © 2018 www.massapi.com. 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.