module_implements.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package kawa.standard;
  2. import kawa.lang.*;
  3. import gnu.expr.*;
  4. import gnu.lists.*;
  5. import gnu.bytecode.*;
  6. public class module_implements extends Syntax {
  7. public static final module_implements module_implements
  8. = new module_implements();
  9. static { module_implements.setName("module-implements"); }
  10. public void scanForm (Pair form, ScopeExp defs, Translator tr) {
  11. tr.getModule().setFlag(ModuleExp.SUPERTYPE_SPECIFIED);
  12. super.scanForm(form, defs, tr);
  13. }
  14. public Expression rewriteForm (Pair form, Translator tr) {
  15. Object args = form.getCdr();
  16. int len = LList.listLength(args, false);
  17. if (len < 0)
  18. tr.syntaxError("improper argument list for " + getName());
  19. else {
  20. ClassType[] interfaces = new ClassType[len];
  21. for (int i = 0; i < len; i++) {
  22. Pair pair = (Pair) args;
  23. interfaces[i] = (ClassType) tr.exp2Type(pair);
  24. args = pair.getCdr();
  25. }
  26. ModuleExp module = tr.getModule();
  27. module.setInterfaces(interfaces);
  28. }
  29. return QuoteExp.voidExp;
  30. }
  31. }