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

📄 sortnodes.java

📁 A framework written in Java for implementing high-level and dynamic languages, compiling them into J
💻 JAVA
字号:
// Copyright (c) 2003  Per M.A. Bothner.// This is free software;  for terms and warranty disclaimer see ./COPYING.package gnu.kawa.xml;import gnu.bytecode.*;import gnu.mapping.*;import gnu.expr.*;/** Sort argument nodes in document order. * Uses the SortedNodes class to do the actual work. */public class SortNodes extends Procedure1 implements Inlineable{  public static final SortNodes sortNodes = new SortNodes();  public Object apply1 (Object values)  {    SortedNodes nodes = new SortedNodes();    Values.writeValues(values, nodes);    if (nodes.count > 1)      return nodes;    else if (nodes.count == 0)      return Values.empty;    else      return nodes.get(0);  }  public void compile (ApplyExp exp, Compilation comp, Target target)  {    Expression[] args = exp.getArgs();    if (args.length != 1 || ! comp.mustCompile)      ApplyExp.compile(exp, comp, target);    else      {        Method resultMethod;        if (target instanceof ConsumerTarget            || (target instanceof StackTarget                && target.getType().isSubtype(Compilation.typeValues)))          resultMethod = null;        else          resultMethod = canonicalizeMethod;        ConsumerTarget.compileUsingConsumer(args[0], comp, target,                                            makeSortedNodesMethod,                                            resultMethod);      }  }  public Type getReturnType (Expression[] args)  {    return Compilation.typeObject;  }  public static final ClassType typeSortedNodes    = ClassType.make("gnu.kawa.xml.SortedNodes");  public static final Method makeSortedNodesMethod    = typeSortedNodes.getDeclaredMethod("<init>", 0);  public static final Method canonicalizeMethod    = Compilation.typeValues.getDeclaredMethod("canonicalize", 0);}

⌨️ 快捷键说明

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