com.svincent.smalljava
Class SmallMethod

java.lang.Object
  |
  +--com.svincent.util.BaseObject
        |
        +--com.svincent.smalljava.SmallMember
              |
              +--com.svincent.smalljava.SmallMethod
Direct Known Subclasses:
SmallConstructor

public class SmallMethod
extends SmallMember

Represents a method declaration. To create new method declaration, use one of the method() methods in SmallClass.

Author:
Shawn Vincent
See Also:
SmallClass

Inner Class Summary
static class SmallMethod.Local
          Represents a local variable.
 
Constructor Summary
  SmallMethod(int _modifiers, java.lang.String _name, SmallType.MethodType _type, java.lang.String[] _argNames)
           
  SmallMethod(int _modifiers, java.lang.String _signature, java.lang.String[] _argNames)
           
protected SmallMethod(int _modifiers, java.lang.String _name, java.lang.String _descriptor, SmallType.MethodType _type, java.lang.String[] _argNames)
           
protected SmallMethod(int _modifiers, java.lang.String _name, java.lang.String _descriptor, java.lang.String[] _argNames)
           
  SmallMethod(java.lang.String _name, SmallType.MethodType _type, java.lang.String[] _argNames)
           
  SmallMethod(java.lang.String _signature, java.lang.String[] _argNames)
           
 
Method Summary
 SmallMethod add(Expr expr)
          Add a new expression to this method, and returns, for your convenience, the SmallMethod again, so a convenient and wonderful method.add ().add ()...
 void addLocal(SmallMethod.Local l, Expr initializer)
          Adds a new local variable to this method.
protected  void addParameter(SmallType type, java.lang.String name)
          Add a new parameter to this method: called from the constructor.
 void addThrows(java.lang.String exClassName)
          Add a throws clause to this method for the given exception class name.
protected  int allocVarIndex()
          When a new local variable is added, its index is assigned using this method.
protected  void finalize()
           
 int getArgCount()
          Return the number of parameters this function has.
 java.lang.String getArgName(int i)
          Return the name of argument 'i'
 java.lang.String[] getArgNames()
          Return the names of all arguments
 SmallType getArgType(int i)
          Get the type of argument 'i'.
 SmallType[] getArgTypes()
          Get the types of all arguments.
 java.lang.String getDescriptor()
          Return this method's type descriptor.
 SmallMethod.Local getLocal(java.lang.String name)
          Get the local variable with the given name.
 java.lang.String getName()
          Return the name of this method (not including its descriptor)
 SmallType getReturnType()
          Return the type of the return value of this method.
 SmallType.MethodType getType()
          Return the type of this method.
 void local(SmallType type, java.lang.String name, Expr initializer)
          Add a new local variable to this method, with the given type and initializer.
 void local(java.lang.String descriptor, java.lang.String name, Expr initializer)
          Add a new local variable to this method, with the given type descriptor and initializer.
 java.util.Iterator locals()
          Return an iterator over all local variables of this method.
protected  void writeAsBytecodes(ClassFileWriter out)
           
 void writeAsJava(IndentPrintWriter out)
          Write this method out as Java source code.
protected  void writeBodyAsJava(IndentPrintWriter out)
          Write the body of this method as Java source.
protected  void writeLocalVarDeclsAsJava(IndentPrintWriter out)
          Write local variable declarations as Java source.
 
Methods inherited from class com.svincent.smalljava.SmallMember
getDeclaringClass, isStatic, setDeclaringClass
 
Methods inherited from class com.svincent.util.BaseObject
dump, dump, dumpToString, tag
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmallMethod

public SmallMethod(java.lang.String _signature,
                   java.lang.String[] _argNames)
            throws SmallJavaBuildingException

SmallMethod

public SmallMethod(int _modifiers,
                   java.lang.String _signature,
                   java.lang.String[] _argNames)
            throws SmallJavaBuildingException

SmallMethod

protected SmallMethod(int _modifiers,
                      java.lang.String _name,
                      java.lang.String _descriptor,
                      java.lang.String[] _argNames)
               throws SmallJavaBuildingException

SmallMethod

public SmallMethod(java.lang.String _name,
                   SmallType.MethodType _type,
                   java.lang.String[] _argNames)
            throws SmallJavaBuildingException

SmallMethod

public SmallMethod(int _modifiers,
                   java.lang.String _name,
                   SmallType.MethodType _type,
                   java.lang.String[] _argNames)
            throws SmallJavaBuildingException

SmallMethod

protected SmallMethod(int _modifiers,
                      java.lang.String _name,
                      java.lang.String _descriptor,
                      SmallType.MethodType _type,
                      java.lang.String[] _argNames)
               throws SmallJavaBuildingException
Method Detail

getName

public java.lang.String getName()
Return the name of this method (not including its descriptor)

getDescriptor

public java.lang.String getDescriptor()
Return this method's type descriptor.

getArgCount

public int getArgCount()
Return the number of parameters this function has.

getArgType

public SmallType getArgType(int i)
Get the type of argument 'i'.

getArgTypes

public SmallType[] getArgTypes()
Get the types of all arguments.

getArgName

public java.lang.String getArgName(int i)
Return the name of argument 'i'

getArgNames

public java.lang.String[] getArgNames()
Return the names of all arguments

getReturnType

public SmallType getReturnType()
Return the type of the return value of this method.

getType

public SmallType.MethodType getType()
Return the type of this method.

addThrows

public void addThrows(java.lang.String exClassName)
Add a throws clause to this method for the given exception class name.

getLocal

public SmallMethod.Local getLocal(java.lang.String name)
Get the local variable with the given name.

locals

public java.util.Iterator locals()
Return an iterator over all local variables of this method.

addParameter

protected void addParameter(SmallType type,
                            java.lang.String name)
                     throws SmallJavaBuildingException
Add a new parameter to this method: called from the constructor.

allocVarIndex

protected int allocVarIndex()
When a new local variable is added, its index is assigned using this method.

add

public SmallMethod add(Expr expr)
Add a new expression to this method, and returns, for your convenience, the SmallMethod again, so a convenient and wonderful method.add ().add ()... form of programming.

local

public void local(java.lang.String descriptor,
                  java.lang.String name,
                  Expr initializer)
           throws SmallJavaBuildingException
Add a new local variable to this method, with the given type descriptor and initializer.

local

public void local(SmallType type,
                  java.lang.String name,
                  Expr initializer)
           throws SmallJavaBuildingException
Add a new local variable to this method, with the given type and initializer.

addLocal

public void addLocal(SmallMethod.Local l,
                     Expr initializer)
              throws SmallJavaBuildingException
Adds a new local variable to this method. It is usually more convenient to call local instead.
See Also:
local(String,String,Expr), local(SmallType,String,Expr)

finalize

protected void finalize()
                 throws SmallJavaValidationException
Overrides:
finalize in class SmallMember

writeAsBytecodes

protected void writeAsBytecodes(ClassFileWriter out)

writeAsJava

public void writeAsJava(IndentPrintWriter out)
Write this method out as Java source code.
Overrides:
writeAsJava in class SmallMember

writeBodyAsJava

protected void writeBodyAsJava(IndentPrintWriter out)
Write the body of this method as Java source.

writeLocalVarDeclsAsJava

protected void writeLocalVarDeclsAsJava(IndentPrintWriter out)
Write local variable declarations as Java source.



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.