All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scm.autogen.autogen Maven / Gradle / Ivy

package scm.autogen;
                                // Generate glue code

import java.io.*;
import java.util.*;

class typeinfo
{
  String scm_name;
  String java_name;
  String java_inp_type[];

  typeinfo(String sname, String jname, String jit[])
  {
    scm_name = sname;
    java_name = jname;
    java_inp_type = jit;
  }

  void write(PrintStream out)
  {
    int mode;

    out.println("//Autogenerated by typeinfo on " + new Date());

    out.println("class scm" + java_name + " extends Procedure implements Obj");
    out.println("{");
    out.println("  Obj apply(Cell args, Env f)\n  throws Exception\n  {");
    out.println("    Cell t = args;");
    out.println("    Obj  tmp;");
    for (int i=0; i\"); }");
    out.println("}");
  }
}

class procinfo
                                // Create simple procedures
                                // automatically
{
  String java_name;
  String scm_name;
  String java_inp_type[];

  procinfo(String sname, String jname, String jit[])
  {
    java_name = jname;
    scm_name = sname;
    java_inp_type = jit;
  }

  void write(PrintStream out)
  {
    int mode;

    out.println("//Autogenerated by procinfo on " + new Date());
    out.println
      ("class scm" + java_name + " extends Procedure implements Obj\n{");
    out.println
      ("  Obj apply(Cell args, Env f)\n  throws Exception\n  {\n");
    out.println
      ("    Cell t = args;");
    out.println
      ("    Obj tmp;");
    for (int i=0; i\"); }");
    out.println("}");
  }
}

class autogen implements jas.RuntimeConstants
{

  static String procs[][] =
    {
                                // Manipulate class env
      {"ClassEnv", "CP"}, {"jas-class-addcpe", "addCPItem"},
      {"ClassEnv", "Var"}, {"jas-class-addfield", "addField"},
      {"ClassEnv", "CP"}, {"jas-class-addinterface", "addInterface"},
      {"ClassEnv", "CP"}, {"jas-class-setclass", "setClass"},
      {"ClassEnv", "CP"}, {"jas-class-setsuperclass", "setSuperClass"},
      {"ClassEnv", "short", "String", "String", "CodeAttr", "ExceptAttr"},
                          {"jas-class-addmethod", "addMethod"},
      {"ClassEnv", "short"}, {"jas-class-setaccess", "setClassAccess"},
      {"ClassEnv", "String"}, {"jas-class-setsource", "setSource"},
      {"ClassEnv", "scmOutputStream"}, {"jas-class-write", "write"},

                                // Add things to exceptions
      {"ExceptAttr", "CP"}, {"jas-exception-add", "addException"},

                                // Manipulate code attrs
      {"CodeAttr", "Insn"}, {"jas-code-addinsn", "addInsn"},
      {"CodeAttr", "short"}, {"jas-code-stack-size", "setStackSize"},
      {"CodeAttr", "short"}, {"jas-code-var-size", "setVarSize"},
      {"CodeAttr", "Catchtable"}, {"jas-set-catchtable", "setCatchtable"},


                                // add things to catchtables
      {"Catchtable", "CatchEntry"}, {"jas-add-catch-entry", "addEntry"},
    };

  static String types[][] =
    {
      {"String"}, {"make-ascii-cpe", "AsciiCP"},
      {"String"}, {"make-class-cpe", "ClassCP"},
      {"String", "String"}, {"make-name-type-cpe", "NameTypeCP"},
      {"String", "String", "String"}, {"make-field-cpe", "FieldCP"},
      {"String", "String", "String"}, {"make-interface-cpe", "InterfaceCP"},
      {"String", "String", "String"}, {"make-method-cpe", "MethodCP"},
      {"int"}, {"make-integer-cpe", "IntegerCP"},
      {"float"}, {"make-float-cpe", "FloatCP"},
      {"long"}, {"make-long-cpe", "LongCP"},
      {"double"}, {"make-double-cpe", "DoubleCP"},
      {"String"}, {"make-string-cpe", "StringCP"},
      {"short", "CP", "CP", "ConstAttr"}, {"make-field", "Var"},
      {"CP"}, {"make-const", "ConstAttr"},
      {"String"}, {"make-outputstream", "scmOutputStream"},
      {"String"}, {"make-label", "Label"},
      {}, {"make-class-env", "ClassEnv"},
      {}, {"make-code", "CodeAttr"},
      {}, {"make-exception", "ExceptAttr"},
      {}, {"make-catchtable", "Catchtable"},
      {"Label", "Label", "Label", "CP"}, {"make-catch-entry", "CatchEntry"},
      {"int", "int"}, {"iinc", "IincInsn"},
      {"CP", "int"}, {"multianewarray", "MultiarrayInsn"},
      {"CP", "int"}, {"invokeinterface", "InvokeinterfaceInsn"},
    };

  public static void main(String argv[])
    throws IOException
  {

    PrintStream initer =
      new PrintStream(new FileOutputStream("AutoInit.java"));
    initer.println("package scm;\n\nimport jas.*;");
    initer.println("class AutoInit\n{\n  static void fillit(Env e)\n  {");

                                // Generate types in the system.
    PrintStream doit = new PrintStream(new FileOutputStream("AutoTypes.java"));
    doit.println("package scm;\n\nimport jas.*;");
    for (int x = 0; x




© 2015 - 2025 Weber Informatics LLC | Privacy Policy