com.svincent.smalljava
Class SmallMacro

java.lang.Object
  |
  +--com.svincent.util.BaseObject
        |
        +--com.svincent.smalljava.SmallMacro

public class SmallMacro
extends BaseObject

A small library of useful expression generators for SmallJava.

Author:
Shawn Vincent

Method Summary
static Expr forLoop(SmallMethod method, java.lang.String varName, int start, int end, Expr body)
          Builds a for loop.
static Expr printField(java.lang.String className, java.lang.String descriptor, java.lang.String fieldName)
          Calls Util.out.print, printing the given field reference.
static Expr println()
          Calls Util.out.println ();
static Expr println(java.lang.String msg)
          Calls Util.out.println ("msg");
static Expr printLocal(SmallMethod method, java.lang.String fieldName)
          Calls Util.out.print, printing the given local field reference.
 
Methods inherited from class com.svincent.util.BaseObject
dump, dump, dumpToString, tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forLoop

public static Expr forLoop(SmallMethod method,
                           java.lang.String varName,
                           int start,
                           int end,
                           Expr body)
                    throws SmallJavaBuildingException
Builds a for loop.

Builds

   for ([varName]=[start]; [varName]<[end]; [varName]++)
     [body]
 
into the given method.

Note that the local int variable must be defined before calling this method, like so:

   // --- print the integers between 0 and 9, inclusive.
   method.local ("I", "i", new Expr.IntConst (0));
   method.add (SmallMacro.forLoop (method, "i", 0, 10, 
                                   SmallMacro.printLocal (method, "i")));
 

println

public static Expr println()
                    throws SmallJavaBuildingException
Calls Util.out.println ();

println

public static Expr println(java.lang.String msg)
                    throws SmallJavaBuildingException
Calls Util.out.println ("msg");

printField

public static Expr printField(java.lang.String className,
                              java.lang.String descriptor,
                              java.lang.String fieldName)
                       throws SmallJavaBuildingException
Calls Util.out.print, printing the given field reference.

printLocal

public static Expr printLocal(SmallMethod method,
                              java.lang.String fieldName)
                       throws SmallJavaBuildingException
Calls Util.out.print, printing the given local field reference.



This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/

Copyright © 1999 Shawn P. Vincent.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.