当前位置: 首页>>代码示例>>Java>>正文


Java MakeAnnotation类代码示例

本文整理汇总了Java中gnu.kawa.reflect.MakeAnnotation的典型用法代码示例。如果您正苦于以下问题:Java MakeAnnotation类的具体用法?Java MakeAnnotation怎么用?Java MakeAnnotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MakeAnnotation类属于gnu.kawa.reflect包,在下文中一共展示了MakeAnnotation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateApply

import gnu.kawa.reflect.MakeAnnotation; //导入依赖的package包/类
public Expression validateApply (ApplyExp exp, InlineCalls visitor,
                                  Type required, Declaration decl)
 {
   if (this == QuoteExp.undefined_exp)
     return exp;
   Object fval = getValue();
   if (! (fval instanceof Procedure))
     return visitor.noteError(decl == null || fval == null ? "called value is not a procedure"
		      : ("calling " + decl.getName()
			 + " which is a "+fval.getClass().getName()));
   Procedure proc = (Procedure) fval;
   int nargs = exp.getArgCount();
   int spliceCount = exp.spliceCount();
   String msg = WrongArguments.checkArgCount(proc, nargs-spliceCount,
                                             spliceCount>0);
   if (msg != null)
     return visitor.noteError(msg);
   Expression inlined = visitor.maybeInline(exp, required, proc);
   if (inlined != null)
     return inlined;
   Expression[] args = exp.args;
   MethodProc asMProc = proc instanceof MethodProc ? (MethodProc) proc : null;
   // FIXME There is duplicate work with resolving parameter types first
   // here then in PrimProcedure.getMethodFor.  For an overloaded method
   // or GenericProc we should try to narrow down applicable methods before
   // validating the arguments, as in CompileInvoke.
   for (int i = 0;  i < nargs;  i++)
     {
       Type ptype = asMProc != null ? asMProc.getParameterType(i) : null;
       // The final varargs parameter T[] can match T or T[].
       if (i == nargs - 1 && ptype != null
           && asMProc.maxArgs() < 0 && i == asMProc.minArgs())
         ptype = null;
       args[i] = visitor.visit(args[i],
                               InlineCalls.ValueNeededType.make(ptype));
     }
   Compilation comp = visitor.getCompilation();
   if (exp.getFlag(ApplyExp.INLINE_IF_CONSTANT))
     {
Expression e = exp.inlineIfConstant(proc, visitor);
if (e != exp)
  return visitor.visit(e, required);
       if (proc == MakeAnnotation.makeMethodProc && nargs == 1 && visitor.processingAnnotations())
         {
           Object name = null;
           if (args[0] instanceof ReferenceExp)
             name = ((ReferenceExp) args[0]).getName();
           msg = "unknown annotation type";
           if (name != null)
             msg = msg + " '" + name + '\'';
           comp.error('e', msg, args[0]);
         }
     }
   if (comp.inlineOk(proc) && exp.isSimple()
       && ! ApplyExp.isInlineable(proc))
     {
PrimProcedure mproc
  = PrimProcedure.getMethodFor(proc, decl, exp.args,
			       comp.getLanguage());
if (mproc != null)
  {
    ApplyExp nexp;
    if (mproc.getStaticFlag() || decl == null)
      nexp = new ApplyExp(mproc, exp.args);
    else if (decl.base == null)
      return exp;
    else
      {
	Expression[] margs = new Expression[1 + nargs];
	System.arraycopy(exp.getArgs(), 0, margs, 1, nargs);
	margs[0] = new ReferenceExp(decl.base);
	nexp = new ApplyExp(mproc, margs);
      }
    return nexp.setLine(exp);
  }
     }
   return exp;
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:79,代码来源:QuoteExp.java

示例2: validateApply

import gnu.kawa.reflect.MakeAnnotation; //导入依赖的package包/类
public Expression validateApply (ApplyExp exp, InlineCalls visitor,
                                  Type required, Declaration decl)
 {
   if (this == QuoteExp.undefined_exp)
     return exp;
   Object fval = getValue();
   if (! (fval instanceof Procedure))
     return visitor.noteError(decl == null || fval == null ? "called value is not a procedure"
		      : ("calling " + decl.getName()
			 + " which is a "+fval.getClass().getName()));
   Procedure proc = (Procedure) fval;
   int nargs = exp.getArgCount();
   String msg = WrongArguments.checkArgCount(proc, nargs);
   if (msg != null)
     return visitor.noteError(msg);
   Expression inlined = visitor.maybeInline(exp, required, proc);
   if (inlined != null)
     return inlined;
   Expression[] args = exp.args;
   MethodProc asMProc = proc instanceof MethodProc ? (MethodProc) proc : null;
   for (int i = 0;  i < nargs;  i++)
     {
       Type ptype = asMProc != null ? asMProc.getParameterType(i) : null;
       // The final varargs parameter T[] can match T or T[].
       if (i == nargs - 1 && ptype != null
           && asMProc.maxArgs() < 0 && i == asMProc.minArgs())
         ptype = null;
       args[i] = visitor.visit(args[i],
                               InlineCalls.ValueNeededType.make(ptype));
     }
   Compilation comp = visitor.getCompilation();
   if (exp.getFlag(ApplyExp.INLINE_IF_CONSTANT))
     {
Expression e = exp.inlineIfConstant(proc, visitor);
if (e != exp)
  return visitor.visit(e, required);
       if (proc == MakeAnnotation.makeMethodProc && nargs == 1 && visitor.processingAnnotations())
         {
           Object name = null;
           if (args[0] instanceof ReferenceExp)
             name = ((ReferenceExp) args[0]).getName();
           msg = "unknown annotation type";
           if (name != null)
             msg = msg + " '" + name + '\'';
           comp.error('e', msg, args[0]);
         }
     }
   if (comp.inlineOk(proc))
     {
if (ApplyExp.asInlineable(proc) != null)
         {
           if (exp.getFunction() == this)
             return exp;
           return new ApplyExp(this, exp.getArgs()).setLine(exp);
         }
PrimProcedure mproc
  = PrimProcedure.getMethodFor(proc, decl, exp.args,
			       comp.getLanguage());
if (mproc != null)
  {
    ApplyExp nexp;
    if (mproc.getStaticFlag() || decl == null)
      nexp = new ApplyExp(mproc, exp.args);
    else if (decl.base == null)
      return exp;
    else
      {
	Expression[] margs = new Expression[1 + nargs];
	System.arraycopy(exp.getArgs(), 0, margs, 1, nargs);
	margs[0] = new ReferenceExp(decl.base);
	nexp = new ApplyExp(mproc, margs);
      }
    return nexp.setLine(exp);
  }
     }
   return exp;
 }
 
开发者ID:alain91,项目名称:kawa,代码行数:78,代码来源:QuoteExp.java


注:本文中的gnu.kawa.reflect.MakeAnnotation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。