Examples of BuiltInFunction


Examples of com.salesforce.phoenix.parse.FunctionParseNode.BuiltInFunction

            return true;
        }
    }

    private static void addBuiltInFunction(Class<? extends FunctionExpression> f) throws Exception {
        BuiltInFunction d = f.getAnnotation(BuiltInFunction.class);
        if (d == null) {
            return;
        }
        int nArgs = d.args().length;
        BuiltInFunctionInfo value = new BuiltInFunctionInfo(f, d);
        do {
            // Add function to function map, throwing if conflicts found
            // Add entry for each possible version of function based on arguments that are not required to be present (i.e. arg with default value)
            BuiltInFunctionKey key = new BuiltInFunctionKey(value.getName(), nArgs);
            if (BUILT_IN_FUNCTION_MAP.put(key, value) != null) {
                throw new IllegalStateException("Multiple " + value.getName() + " functions with " + nArgs + " arguments");
            }
        } while (--nArgs >= 0 && d.args()[nArgs].defaultValue().length() > 0);

        // Look for default values that aren't at the end and throw
        while (--nArgs >= 0) {
            if (d.args()[nArgs].defaultValue().length() > 0) {
                throw new IllegalStateException("Function " + value.getName() + " has non trailing default value of '" + d.args()[nArgs].defaultValue() + "'. Only trailing arguments may have default values");
            }
        }
    }
View Full Code Here

Examples of erjang.beam.BuiltInFunction

            int failLabel = decode_labelref(insn.label, type_map.exh);
            Arg[] in = new Arg[] {src_arg(insn_idx, insn.src)};
            Type[] inTypes = new Type[] {in[0].type};
            Arg out = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(), inTypes,
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }
         
          case fconv:
          case fmove:
          case move: {
            Insn.SD insn = (Insn.SD)insn_;
            Arg src  = src_arg(insn_idx, insn.src);
            Arg dest = dest_arg(insn_idx, insn.dest);

            if (insns.size() > insn_idx+1) {
            Insn next_insn = insns.get(insn_idx+1);
            if (next_insn.opcode() == BeamOpcode.K_return) {
              vis.visitInsn(BeamOpcode.K_return, src);
              insn_idx += 1;
              break;
            }
            }
           
            if (dest.kind != Kind.F) {
              if (src.kind == Kind.F) {
                dest = new Arg(dest, EDOUBLE_TYPE);
              } else {
                dest = new Arg(dest, src.type);
              }
            } else {
              // arg2.kind == F
            }

            vis.visitInsn(opcode, src, dest);
            break;
          }

          case put_string: {
            Insn.ByD insn = (Insn.ByD)insn_;
            Arg src  = src_arg(insn_idx, insn.bin);
            Arg dest = dest_arg(insn_idx, insn.dest);
//             Arg arg1 = decode_arg(insn_idx, insn.elm(3));
//             Arg arg2 = decode_out_arg(insn_idx, insn.elm(4));
            dest = new Arg(dest, ESEQ_TYPE);
            vis.visitInsn(BeamOpcode.move, src, dest);
            break;
          }

          case fadd:
          case fsub:
          case fmul:
          case fdiv:
          {
            Insn.LSSD insn = (Insn.LSSD)insn_;
            EAtom name = opcode.symbol;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            Arg[] in = new Arg[] {src_arg(insn_idx, insn.src1),
                        src_arg(insn_idx, insn.src2)};
            Type[] inTypes = new Type[] {in[0].type,
                           in[1].type};
            Arg out = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(), inTypes,
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }

          case bif0:
          case bif1:
          case bif2:
          {
            Insn.Bif insn = (Insn.Bif)insn_;
            EAtom name = insn.ext_fun.fun;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            SourceOperand[] srcs = insn.args;
            Arg[] in = src_args(insn_idx, srcs);
            Arg out  = dest_arg(insn_idx, insn.dest);

            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(),
                parmTypes(type_map, srcs),
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
          }

           case gc_bif1:
           case gc_bif2:
           case gc_bif3:
          {
            Insn.GcBif insn = (Insn.GcBif)insn_;
            EAtom name = insn.ext_fun.fun;
            int failLabel = decode_labelref(insn.label, type_map.exh);
            SourceOperand[] srcs = insn.args;
            Arg[] in = src_args(insn_idx, srcs);
            Arg out  = dest_arg(insn_idx, insn.dest);

            // special case for X+1, 1+X, X-1.
            Int lop = null, rop = null;
            if (srcs.length==2
                && (((name==am_plus || name == am_minus) && (rop=srcs[1].testInt()) != null && rop.equals(1))
                 || (name==am_plus && (lop=srcs[0].testInt()) != null && lop.equals(1))))
            {
              if (name == am_plus) {
                Arg src = (lop == null) ? in[0] : in[1];
               
                vis.visitIncrement(src, out);
                break;
              } else if (name == am_minus) {
                Arg src = in[0];
                vis.visitDecrement(src, out);
                break;               
              }
            }
           
            BuiltInFunction bif = BIFUtil.getMethod("erlang", name.getName(),
                parmTypes(type_map, srcs),
                failLabel != 0, true);

            vis.visitInsn(opcode, failLabel, in, out, bif);
            break;
View Full Code Here

Examples of erjang.beam.BuiltInFunction

    ESmall ary = a.testSmall();
   
    if (mod == null || fun == null || ary == null)
      throw ERT.badarg(m, f, a);
   
    BuiltInFunction bif = BIFUtil.getMethod(mod, fun, ary.value, false, false);
    return ERT.box( bif != null );
  }
View Full Code Here

Examples of org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction

            return true;
        }
    }

    private static void addBuiltInFunction(Class<? extends FunctionExpression> f) throws Exception {
        BuiltInFunction d = f.getAnnotation(BuiltInFunction.class);
        if (d == null) {
            return;
        }
        int nArgs = d.args().length;
        BuiltInFunctionInfo value = new BuiltInFunctionInfo(f, d);
        do {
            // Add function to function map, throwing if conflicts found
            // Add entry for each possible version of function based on arguments that are not required to be present (i.e. arg with default value)
            BuiltInFunctionKey key = new BuiltInFunctionKey(value.getName(), nArgs);
            if (BUILT_IN_FUNCTION_MAP.put(key, value) != null) {
                throw new IllegalStateException("Multiple " + value.getName() + " functions with " + nArgs + " arguments");
            }
        } while (--nArgs >= 0 && d.args()[nArgs].defaultValue().length() > 0);

        // Look for default values that aren't at the end and throw
        while (--nArgs >= 0) {
            if (d.args()[nArgs].defaultValue().length() > 0) {
                throw new IllegalStateException("Function " + value.getName() + " has non trailing default value of '" + d.args()[nArgs].defaultValue() + "'. Only trailing arguments may have default values");
            }
        }
    }
View Full Code Here

Examples of org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction

            return true;
        }
    }

    private static void addBuiltInFunction(Class<? extends FunctionExpression> f) throws Exception {
        BuiltInFunction d = f.getAnnotation(BuiltInFunction.class);
        if (d == null) {
            return;
        }
        int nArgs = d.args().length;
        BuiltInFunctionInfo value = new BuiltInFunctionInfo(f, d);
        do {
            // Add function to function map, throwing if conflicts found
            // Add entry for each possible version of function based on arguments that are not required to be present (i.e. arg with default value)
            BuiltInFunctionKey key = new BuiltInFunctionKey(value.getName(), nArgs);
            if (BUILT_IN_FUNCTION_MAP.put(key, value) != null) {
                throw new IllegalStateException("Multiple " + value.getName() + " functions with " + nArgs + " arguments");
            }
        } while (--nArgs >= 0 && d.args()[nArgs].defaultValue().length() > 0);

        // Look for default values that aren't at the end and throw
        while (--nArgs >= 0) {
            if (d.args()[nArgs].defaultValue().length() > 0) {
                throw new IllegalStateException("Function " + value.getName() + " has non trailing default value of '" + d.args()[nArgs].defaultValue() + "'. Only trailing arguments may have default values");
            }
        }
    }
View Full Code Here

Examples of org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction

            return true;
        }
    }

    private static void addBuiltInFunction(Class<? extends FunctionExpression> f) throws Exception {
        BuiltInFunction d = f.getAnnotation(BuiltInFunction.class);
        if (d == null) {
            return;
        }
        int nArgs = d.args().length;
        BuiltInFunctionInfo value = new BuiltInFunctionInfo(f, d);
        do {
            // Add function to function map, throwing if conflicts found
            // Add entry for each possible version of function based on arguments that are not required to be present (i.e. arg with default value)
            BuiltInFunctionKey key = new BuiltInFunctionKey(value.getName(), nArgs);
            if (BUILT_IN_FUNCTION_MAP.put(key, value) != null) {
                throw new IllegalStateException("Multiple " + value.getName() + " functions with " + nArgs + " arguments");
            }
        } while (--nArgs >= 0 && d.args()[nArgs].defaultValue().length() > 0);

        // Look for default values that aren't at the end and throw
        while (--nArgs >= 0) {
            if (d.args()[nArgs].defaultValue().length() > 0) {
                throw new IllegalStateException("Function " + value.getName() + " has non trailing default value of '" + d.args()[nArgs].defaultValue() + "'. Only trailing arguments may have default values");
            }
        }
    }
View Full Code Here

Examples of org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction

            return true;
        }
    }

    private static void addBuiltInFunction(Class<? extends FunctionExpression> f) throws Exception {
        BuiltInFunction d = f.getAnnotation(BuiltInFunction.class);
        if (d == null) {
            return;
        }
        int nArgs = d.args().length;
        BuiltInFunctionInfo value = new BuiltInFunctionInfo(f, d);
        do {
            // Add function to function map, throwing if conflicts found
            // Add entry for each possible version of function based on arguments that are not required to be present (i.e. arg with default value)
            BuiltInFunctionKey key = new BuiltInFunctionKey(value.getName(), nArgs);
            if (BUILT_IN_FUNCTION_MAP.put(key, value) != null) {
                throw new IllegalStateException("Multiple " + value.getName() + " functions with " + nArgs + " arguments");
            }
        } while (--nArgs >= 0 && d.args()[nArgs].defaultValue().length() > 0);

        // Look for default values that aren't at the end and throw
        while (--nArgs >= 0) {
            if (d.args()[nArgs].defaultValue().length() > 0) {
                throw new IllegalStateException("Function " + value.getName() + " has non trailing default value of '" + d.args()[nArgs].defaultValue() + "'. Only trailing arguments may have default values");
            }
        }
    }
View Full Code Here

Examples of xbird.xquery.func.BuiltInFunction

                    _hasContextualFilter = true;
                    continue;
                }
            } else if(e instanceof FunctionCall) {
                FunctionCall fc = (FunctionCall) e;
                BuiltInFunction fnlast = PredefinedFunctions.lookup(Last.SYMBOL);
                if(fnlast.getName().equals(fc.getFuncName())) { // if fn:last()
                    final LastFilter filter = new LastFilter(baseType);
                    _predicates.set(i, filter);
                    baseType = filter.getType();
                    _hasContextualFilter = true;
                    continue;
View Full Code Here

Examples of xbird.xquery.func.BuiltInFunction

    @Override
    public void writeExternal(ObjectOutput out) throws IOException {
        super.writeExternal(out);
        if(func instanceof BuiltInFunction) {
            out.writeBoolean(true);
            BuiltInFunction builtIn = (BuiltInFunction) func;
            builtIn.writeTo(out);
        } else {
            out.writeBoolean(false);
            out.writeObject(func);
        }
    }
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.