Package abstrasy.pcfx

Source Code of abstrasy.pcfx.PCFx_hash

package abstrasy.pcfx;


import abstrasy.Hash;
import abstrasy.Node;
import abstrasy.PCoder;

import java.util.ArrayList;


/**
* 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_hash extends PCFx {

  public PCFx_hash() {
  }

  /**
   * eval
   *
   * @param startAt Node
   * @return Node
   * @throws Exception
   * @todo Implémenter cette méthode abstrasy.PCFx
   */
  public Node eval(Node startAt) throws Exception {
    /*
     * forme:   (hash) -> hash vide
         *          (hash @ id0 valeur0 @ id1 valeur1 ... @ idN valeurN)
         *         
         *          (hash hash)
         *         
     */
   
   
        Node nhash=Node.createHash();
        Hash hash=nhash.getHash();
       
        if(startAt.size()==2){
            //
            // forme (hash hash)
            //
            Hash hash2=startAt.getSubNode(1, Node.TYPE_HASH).getHash();
            ArrayList<Node> kn=hash2.keys_nodes();
            for(int i=0;i<kn.size();i++)
                hash.store(kn.get(i), hash2.ref(kn.get(i)).secure());
            return nhash;
        }
       
        //   
        // autres formes...
        //
        int i=1;
        while(i<startAt.size()){
            startAt.requirePCode(i++, PCoder.PC_REFsucre);
            Node k = startAt.getSubNode(i++, Hash.KEY_TYPES);
            Node v = startAt.getSubNode(i++, Node.VTYPE_VALUABLE);
            v.derefTo(hash.ref(k));
        }
       
    return nhash;
  }

}
TOP

Related Classes of abstrasy.pcfx.PCFx_hash

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.