⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makeattribute.java

📁 A framework written in Java for implementing high-level and dynamic languages, compiling them into J
💻 JAVA
字号:
// Copyright (c) 2001, 2004  Per M.A. Bothner and Brainfood Inc.// This is free software;  for terms and warranty disclaimer see ./COPYING.package gnu.kawa.xml;import gnu.lists.*;import gnu.mapping.*;import gnu.expr.*;import gnu.bytecode.*;public class MakeAttribute extends NodeConstructor{  public static final MakeAttribute makeAttribute = new MakeAttribute();  public static final QuoteExp makeAttributeExp = new QuoteExp(makeAttribute);  public int numArgs() { return 0xFFFFF001; }  public static void startAttribute(Consumer out, Object type)  {    out.startAttribute(type);  }  public void apply (CallContext ctx)  {    Consumer saved = ctx.consumer;    Consumer out = pushNodeContext(ctx);    try      {	Object type = ctx.getNextArg();	startAttribute(out, type);	Object endMarker = Special.dfault;	for (;;)	  {	    Object arg = ctx.getNextArg(endMarker);	    if (arg == endMarker)	      break;	    if (arg instanceof Consumable)	      ((Consumable) arg).consume(out);	    else	      ctx.writeValue(arg);	  }	out.endAttribute();      }    finally      {	popNodeContext(saved, ctx);      }  }  public void compileToNode (ApplyExp exp, Compilation comp,				      ConsumerTarget target)  {    Variable consumer = ((ConsumerTarget) target).getConsumerVariable();    Expression[] args = exp.getArgs();    int nargs = args.length;    CodeAttr code = comp.getCode();    code.emitLoad(consumer);    code.emitDup();    args[0].compile(comp, Target.pushObject);    // Stack:  consumer, consumer, tagtype    code.emitInvokeStatic(startAttributeMethod);    for (int i = 1;  i < nargs;  i++)      compileChild(args[i], comp, target);    code.emitInvokeInterface(endAttributeMethod);  }  static final ClassType typeMakeAttribute    = ClassType.make("gnu.kawa.xml.MakeAttribute");  static final Method startAttributeMethod    = typeMakeAttribute.getDeclaredMethod("startAttribute", 2);  static final Method endAttributeMethod    = Compilation.typeConsumer.getDeclaredMethod("endAttribute", 0);  public Type getReturnType (Expression[] args)  {    return Compilation.typeObject;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -