Examples of Func


Examples of edu.mit.csail.sdg.alloy4compiler.ast.Func

      }
      status=3;
      dup(p, n, false);
      ExprHasName dup = Decl.findDuplicateName(decls);
      if (dup!=null) throw new ErrorSyntax(dup.span(), "The parameter name \""+dup.label+"\" cannot appear more than once.");
      Func ans = new Func(p, isPrivate, n, decls, t, v);
      ArrayList<Func> list = funcs.get(n);
      if (list==null) { list = new ArrayList<Func>(); funcs.put(n, list); }
      list.add(ans);
   }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Func

   /** Each FunAST will now point to a bodyless Func object. */
   private JoinableList<Err> resolveFuncDecls(A4Reporter rep, JoinableList<Err> errors, List<ErrorWarning> warns) throws Err {
      for(ArrayList<Func> list: funcs.values()) {
         for(int listi=0; listi<list.size(); listi++) {
            Func f = list.get(listi);
            String fullname = (path.length()==0 ? "this/" : (path+"/")) + f.label;
            // Each PARAMETER can refer to earlier parameter in the same function, and any SIG or FIELD visible from here.
            // Each RETURNTYPE can refer to the parameters of the same function, and any SIG or FIELD visible from here.
            Context cx = new Context(this, warns);
            cx.rootfunparam = true;
            TempList<Decl> tmpdecls = new TempList<Decl>();
            boolean err = false;
            for(Decl d: f.decls) {
               TempList<ExprVar> tmpvars = new TempList<ExprVar>();
               Expr val = cx.check(d.expr).resolve_as_set(warns);
               if (!val.errors.isEmpty()) { err = true; errors = errors.make(val.errors); }
               for(ExprHasName n: d.names) {
                  ExprVar v = ExprVar.make(n.span(), n.label, val.type());
                  cx.put(n.label, v);
                  tmpvars.add(v);
                  rep.typecheck((f.isPred?"pred ":"fun ")+fullname+", Param "+n.label+": "+v.type()+"\n");
               }
               tmpdecls.add(new Decl(d.isPrivate, d.disjoint, d.disjoint2, tmpvars.makeConst(), val));
            }
            Expr ret = null;
            if (!f.isPred) {
               ret = cx.check(f.returnDecl).resolve_as_set(warns);
               if (!ret.errors.isEmpty()) { err = true; errors = errors.make(ret.errors); }
            }
            if (err) continue;
            try {
               f = new Func(f.pos, f.isPrivate, fullname, tmpdecls.makeConst(), ret, f.getBody());
               list.set(listi, f);
               rep.typecheck("" + f + ", RETURN: " + f.returnDecl.type() + "\n");
            } catch(Err ex) { errors = errors.make(ex); }
         }
      }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Func

      } else {
         List<Object> m = getRawQS(4, cname); // We prefer fun/pred in the topmost module
         if (m.size()==0 && cname.indexOf('/')<0) m=getRawNQS(this, 4, cname);
         if (m.size()>1) unique(cmd.pos, cname, m);
         if (m.size()<1) throw new ErrorSyntax(cmd.pos, "The predicate/function \""+cname+"\" cannot be found.");
         Func f = (Func) (m.get(0));
         e = f.getBody();
         if (!f.isPred) e = e.in(f.returnDecl);
         if (f.decls.size()>0) e = ExprQt.Op.SOME.make(null, null, f.decls, e);
      }
      if (e==null) e = ExprConstant.TRUE;
      TempList<CommandScope> sc=new TempList<CommandScope>(cmd.scope.size());
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Func

            Sig y = (Sig)x;
            ch.add(ExprUnary.Op.NOOP.make(pos, y, null, 0));
            re.add("sig "+y.label);
         }
         else if (x instanceof Func) {
            Func f = (Func)x;
            int fn = f.count();
            int penalty = 0;
            if (resolution==1 && fn>0 && rootsig!=null && THIS!=null && THIS.type().hasArity(1) && f.get(0).type().intersects(THIS.type())) {
               // If we're inside a sig, and there is a unary variable bound to "this",
               // we should consider it as a possible FIRST ARGUMENT of a fun/pred call
               ConstList<Expr> t = Util.asList(THIS);
               ch.add(fn==1 ? ExprCall.make(pos, null, f, t, 1+penalty) : ExprBadCall.make(pos, null, f, t, 1+penalty)); // penalty of 1
               re.add((f.isPred?"pred this.":"fun this.")+f.label);
            }
            if (resolution==1) {
               ch.add(fn==0 ? ExprCall.make(pos, null, f, null, penalty) : ExprBadCall.make(pos, null, f, null, penalty));
               re.add((f.isPred?"pred ":"fun ")+f.label);
            }
            if (resolution==2 && f!=rootfunbody && THIS!=null && fullname.charAt(0)!='@' && fn>0 && f.get(0).type().intersects(THIS.type())) {
               // If there is some value bound to "this", we should consider it as a possible FIRST ARGUMENT of a fun/pred call
               ConstList<Expr> t = Util.asList(THIS);
               ch.add(fn==1 ? ExprCall.make(pos, null, f, t, 0) : ExprBadCall.make(pos, null, f, t, 0));
               re.add((f.isPred?"pred this.":"fun this.")+f.label);
            }
            if (resolution!=1) {
               ch.add(fn==0 ? ExprCall.make(pos, null, f, null, 0) : ExprBadCall.make(pos, null, f, null, 0));
               re.add((f.isPred?"pred ":"fun ")+f.label);
            }
         }
      }
      // Within a field decl
      // (1) Can refer to any visible sig/param (but you cannot call any function or predicates)
      // (2) Can refer to field in this sig (defined earlier than you), and fields in any visible ancestor sig
      // Within an appended facts
      // (1) Can refer to any visible sig/param/func/predicate
      // (2) Can refer to any visible field
      // Within a function paramDecl/returnDecl
      // (1) Cannot call
      // (2) But can refer to anything else visible.
      // All else: we can call, and can refer to anything visible.
      for(CompModule m: getAllNameableModules())
         for(Sig s: m.sigs.values()) if (m==this || s.isPrivate==null)
            for(Field f: s.getFields()) if (f.isMeta==null && (m==this || f.isPrivate==null) && f.label.equals(name))
               if (resolution==1) {
                  Expr x=null;
                  if (rootsig==null)
                  { x=ExprUnary.Op.NOOP.make(pos, f, null, 0); }
                  else if (rootsig.isSameOrDescendentOf(f.sig))
                  { x=ExprUnary.Op.NOOP.make(pos, f, null, 0); if (fullname.charAt(0)!='@') x=THIS.join(x); }
                  else if (rootfield==null || rootfield.expr.mult()==ExprUnary.Op.EXACTLYOF)
                  { x=ExprUnary.Op.NOOP.make(pos, f, null, 1); } // penalty of 1
                  if (x!=null) { ch.add(x); re.add("field "+f.sig.label+" <: "+f.label); }
               } else if (rootfield==null || rootsig.isSameOrDescendentOf(f.sig)) {
                  Expr x0 = ExprUnary.Op.NOOP.make(pos, f, null, 0);
                  if (resolution==2 && THIS!=null && fullname.charAt(0)!='@' && f.type().firstColumnOverlaps(THIS.type())) {
                     ch.add(THIS.join(x0));
                     re.add("field "+f.sig.label+" <: this."+f.label);
                     if (rootsig!=null) continue;
                  }
                  ch.add(x0);
View Full Code Here

Examples of l2p.gameserver.skills.funcs.Func

      return _emptyFunctionSet;
    }
    Func[] funcs = new Func[_funcTemplates.length];
    for(int i = 0; i < funcs.length; i++)
    {
      Func f = _funcTemplates[i].getFunc(this); // effect is owner
      funcs[i] = f;
    }
    return funcs;
  }
View Full Code Here

Examples of l2p.gameserver.skills.funcs.Func

    GArray<Func> funcs = new GArray<Func>();
    if(_itemTemplate.getAttachedFuncs() != null)
    {
      for(FuncTemplate t : _itemTemplate.getAttachedFuncs())
      {
        Func f = t.getFunc(this);
        if(f != null)
        {
          funcs.add(f);
        }
      }
    }
    if(_funcTemplates != null)
    {
      for(FuncTemplate t : _funcTemplates)
      {
        Func f = t.getFunc(this);
        if(f != null)
        {
          funcs.add(f);
        }
      }
View Full Code Here

Examples of l2p.gameserver.skills.funcs.Func

      return _emptyFunctionSet;
    }
    GArray<Func> funcs = new GArray<Func>();
    for(FuncTemplate t : _funcTemplates)
    {
      Func f = t.getFunc(this); // skill is owner
      if(f != null)
      {
        funcs.add(f);
      }
    }
View Full Code Here

Examples of l2p.gameserver.skills.funcs.Func

    L2Character owner = _inv.getOwner();
    owner.addStatFuncs(item.getStatFuncs());
    owner.updateStats();
    if(owner.getPet() != null && item.getAttributeFuncTemplate() != null)
    {
      Func f = item.getAttributeFuncTemplate().getFunc(item);
      owner.getPet().addStatFunc(f);
      owner.getPet().updateStats();
    }
  }
View Full Code Here

Examples of lineage2.gameserver.stats.funcs.Func

   
    if (template.getAttachedFuncs().length > 0)
    {
      for (FuncTemplate t : template.getAttachedFuncs())
      {
        Func f = t.getFunc(this);
        if (f != null)
        {
          funcs.add(f);
        }
      }
View Full Code Here

Examples of net.algart.math.functions.Func

        double[] weights = new double[shifted.size()];
        assert weights.length <= 31;
        for (int k = 0; k < weights.length; k++) {
            weights[k] = 1L << k;
        }
        Func packingShiftedBits = LinearFunc.getInstance(0.0, weights);
        return Matrices.asFuncMatrix(packingShiftedBits, IntArray.class, shifted);
    }
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.