Examples of Dict


Examples of jfun.util.dict.Dict

      return ctxt.puts(names, stmts);
    }
    private Stmt compile(){
      current_location.setLocation(getLocation());
      final List subnodes = tag.getSubNodes();
      Dict ctxt = this.ctxt;
      if(BINDER.equals(tag.getName())){
        final String varname = getMandatoryVar(this.tag);
        ctxt = declareName(ctxt, varname, getLocation());
      }
      else if(FUNCTION.equals(tag.getName())){
View Full Code Here

Examples of jfun.util.dict.Dict

        final Node node = (Node)subnodes.get(0);
        if(node instanceof Tag){
          final Tag t = (Tag)node;
          if(LOCAL.equals(t.getName())){
            final LocalScope scope = compileLocalScope(ctxt, t);
            final Dict nctxt = scope.getScope();
            return withScope(scope, compileNut(nutname, desc, nctxt,
                subnodes.subList(1, subnodes.size()), is_subnut), getLocation());
          }
        }
        return compileNut(nutname, desc, ctxt, subnodes, is_subnut);
View Full Code Here

Examples of jfun.util.dict.Dict

      if(id!=null && id.equals(varname)){
        throw raise(ID+" and "+VAR+" cannot share the same value");
      }
      final HashMap local_names = new HashMap();
      local_names.put(varname, varname);
      final Dict nctxt = ctxt;//declareName(ctxt, varname, getLocation());
      final Definition[] stmt = compileDefinitions(nctxt, subnodes, local_names);
      return compileBinder(varname, stmt, 0, stmt.length);
    }
View Full Code Here

Examples of jfun.util.dict.Dict

    return nframe[0];
  }
  static Body evaluate(Object[] keys, Stmt[] stmts,
      Runtime runtime,
      Dict initial_frame){
    final Dict frame = newFrame(keys,
        stmts, initial_frame, runtime);
    final Closure[] closures = new Closure[keys.length];
    final Location[] locations = new Location[keys.length];
    for(int i=0; i<keys.length; i++){
      final Object key = keys[i];
      //final Location iloc = stmts[i].getLocation();
      closures[i] = (Closure)frame.get(key);
      locations[i] = stmts[i].getLocation();
    }
    return new Body(keys, closures, locations);
  }
View Full Code Here

Examples of jfun.util.dict.Dict

      else{
        throw new ConfigurationException("only elements are allowed within "+tagname,
            loc);
      }
    }
    final Dict nctxt = ctxt.puts(keys, bounds);
    final Stmt[] stmts = new Stmt[keys.length];
    for(int i=0; i<keys.length; i++){
      final Tag tag = (Tag)decs.get(i);
      stmts[i] = compileTag(i, nctxt, tag, false, is_global, singleton_mode);
    }
View Full Code Here

Examples of jfun.util.dict.Dict

      public String toString(){
        return "\\"+varname+"->"+stmt;
      }
      public Creator bind(Object v){
        //final Var var = new Var(v);
        Dict nframe = frame.put(varname, v);
        final Object retval = evalStmt(stmt, runtime, nframe);
        return NutsUtils.asComponent(retval);
      }

      public Class bindType(Class type) {
View Full Code Here

Examples of org.python.pydev.parser.jython.ast.Dict

        return col;
    }

    protected final SimpleNode makeDictionaryOrSet(int arity) {
        if (arity == 0) {
            return new Dict(new exprType[0], new exprType[0]);
        }

        SimpleNode dictNode0 = stack.popNode();

        if (dictNode0 instanceof Set) {
            Set set = (Set) dictNode0;
            exprType[] elts = new exprType[arity - 1]; //-1 because the set was already taken from there
            for (int i = arity - 2; i >= 0; i--) { //same thing here
                elts[i] = (exprType) stack.popNode();
            }
            set.elts = elts;
            return set;
        }

        if (dictNode0 instanceof ComprehensionCollection) {
            if (arity == 2) {
                ComprehensionCollection comp = (ComprehensionCollection) dictNode0;
                return new SetComp((exprType) stack.popNode(), comp.getGenerators());

            } else if (arity == 3) {
                SimpleNode dictNode1 = stack.popNode(); //we must inverse things here...
                ComprehensionCollection comp = (ComprehensionCollection) dictNode0;
                return new DictComp((exprType) stack.popNode(), (exprType) dictNode1, comp.getGenerators());
            }
        }

        boolean isDictComplete = arity % 2 == 0;

        int l = arity / 2;
        exprType[] keys;
        if (isDictComplete) {
            keys = new exprType[l];
        } else {
            keys = new exprType[l + 1]; //we have 1 additional entry in the keys (parse error actually, but let's recover at this point!)
        }
        boolean node0Used = false;
        exprType[] vals = new exprType[l];
        for (int i = l - 1; i >= 0; i--) {
            if (!node0Used) {
                node0Used = true;
                vals[i] = (exprType) dictNode0;
                keys[i] = (exprType) stack.popNode();

            } else {
                vals[i] = (exprType) stack.popNode();
                keys[i] = (exprType) stack.popNode();
            }
        }
        if (!isDictComplete) {
            if (node0Used) {
                keys[keys.length - 1] = (exprType) stack.popNode();
            } else {
                keys[keys.length - 1] = (exprType) dictNode0;
            }
        }

        return new Dict(keys, vals);
    }
View Full Code Here

Examples of org.python.pydev.parser.jython.ast.Dict

            keys[i] = (exprType) stack.popNode();
        }
        if (!isDictComplete) {
            keys[keys.length - 1] = (exprType) stack.popNode();
        }
        return new Dict(keys, vals);
    }
View Full Code Here
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.