Math 302, Differential Equations JHU

Math 302X
- HW3.pdf
- Statement on Disabilities
- Statement on Ethics
- Homework
- Java Tools
 
- An example of a circuit
- An example of a circuit
- An example of a circuit
- An Application to Population Dynamics
- An application to Population Dynamics
- Slope Field Calculator
- ODE 2D Calculator
- ODE 2D Calculator
- ODE 3D Calculator
- ODE 3D Calculator
- Slope Field Calculator
- Slope Field Calculator
- Solution Verifier
- Solution Verifier 2D
- Solution Verifier 2D
- Solution Verifier
- A Lotke-Volterra System
- A Lotke-Volterra system
- Labor Managed Oligopoly - Two firms
- ODE 3D Calculator
- 2D Map Calculator
- A model of sunami
- A model of sunami
- The three body problem
- The two body problem
- The two body problem
- Van der Pol Equation
- Van der Pol Equation
- List of parameters of the JOde Applet
- Browser test
- Generated Documentation (Untitled)
 
- All Classes
- All Classes
- Constant Field Values
- Deprecated List
- API Help
- Index
- Overview
- Overview
- Class Hierarchy
-
- Serialized Form
- ODE 2D Calculator
+ Using Marek Rychliks's Applet for Euler's Method
- JOde Manual Page
- JOde - An Applet for Studying Ordinary Differential Equations
- ODE 2D Calculator
- Syllabus
Math Dept. Home
Help room

com.rychlik.calculator
Class StackMachine

java.lang.Object
  |
  +--com.rychlik.calculator.StackMachine
All Implemented Interfaces:
java.io.Serializable

public class StackMachine
extends java.lang.Object
implements java.io.Serializable

Describe class StackMachine here.

Version:
1.0
Author:
Marek Rychlik
See Also:
Serialized Form

Nested Class Summary
 class StackMachine.Abs
          Describe class Abs here.
 class StackMachine.Add
          Describe class Add here.
 class StackMachine.And
          Describe class And here.
 class StackMachine.Asin
          Describe class Asin here.
 class StackMachine.Assign
          Assign the top value on stack to a variable.
 class StackMachine.Atan
          Describe class Atan here.
 class StackMachine.BinaryMathFunction
          Describe class BinaryMathFunction here.
 class StackMachine.Branch
          Describe class Branch here.
 class StackMachine.Call
          Describe class Call here.
 class StackMachine.Constant
          Describe class Constant here.
 class StackMachine.Cos
          Describe class Cos here.
 class StackMachine.Div
          Describe class Div here.
 class StackMachine.DumpStack
          Output the current contents of the stack.
 class StackMachine.Eq
          Describe class Eq here.
 class StackMachine.Exp
          Describe class Exp here.
 class StackMachine.Function
          Describe class Function here.
 class StackMachine.Ge
          Describe class Ge here.
 class StackMachine.GoTo
          Goto
 class StackMachine.Gt
          Describe class Gt here.
 class StackMachine.If
          Describe class If here.
static interface StackMachine.Instruction
          Describe interface Instruction here.
 class StackMachine.Le
          Describe class Le here.
 class StackMachine.Ln
          Describe class Ln here.
 class StackMachine.Lt
          Describe class Lt here.
 class StackMachine.MathFunction
          Describe class MathFunction here.
 class StackMachine.Max
          Describe class Max here.
 class StackMachine.Min
          Describe class Min here.
 class StackMachine.Mul
          Describe class Mul here.
 class StackMachine.Ne
          Describe class Ne here.
 class StackMachine.Negate
          Describe class Negate here.
 class StackMachine.Or
          Describe class Or here.
 class StackMachine.Pop
          Describe class Pop here.
 class StackMachine.PopPrint
          Print the top of the stack.
 class StackMachine.Pow
          Describe class Pow here.
 class StackMachine.Print
          Print the top of the stack.
 class StackMachine.PushAddress
          Push address on stack.
 class StackMachine.PushConstant
          Push constant on stack.
 class StackMachine.PushVariable
          Push value of a variable on stack.
 class StackMachine.Return
          Return from a function
 class StackMachine.Sgn
          Describe class Sgn here.
 class StackMachine.Sin
          Describe class Sin here.
 class StackMachine.Sqrt
          Describe class Sqrt here.
 class StackMachine.Step
          Describe class Step here.
 class StackMachine.Stop
          Describe class Stop here.
 class StackMachine.Sub
          Describe class Sub here.
 class StackMachine.SymbolTableEntry
          Describe class SymbolTableEntry here.
 class StackMachine.Tan
          Describe class Tan here.
 class StackMachine.TernaryMathFunction
          Describe class TernaryMathFunction here.
 class StackMachine.UnaryMathFunction
          Describe class UnaryMathFunction here.
 class StackMachine.Variable
          Describe class Variable here.
 
Constructor Summary
StackMachine()
          Creates a new StackMachine instance.
 
Method Summary
 int allocateVariable()
          Add a new uninitialized variable.
 int allocateVariable(double value)
          Add a new initialized variable.
 void assign(int address, double value)
          Assign value to a variable.
 void clear()
          Describe clear method here.
 void clearData()
          Describe clearData method here.
 void clearGlobalSymbolTable()
          Describe clearGlobalSymbolTable method here.
 void clearLocalSymbolTable()
          Describe clearLocalSymbolTable method here.
 void clearProgram()
          Describe clearProgram method here.
 void clearProgram(int beg)
          Describe clearProgram method here.
 void clearReturnStack()
          Describe clearReturnStack method here.
 void clearStack()
          Describe clearStack method here.
 void createConstant(java.lang.String id, double value)
          Create a new constant and place it in the global symbol table.
 void createFunction(java.lang.String id, int progbase, int argbase, int nargs)
          Describe createFunction method here.
 StackMachine.Variable createVariable(java.lang.String id)
          Create a new global variable.
 StackMachine.Variable createVariable(java.lang.String id, double value)
          Create a new global variable.
 void dumpStack()
          Describe dumpStack method here.
 void enterLocalScope()
          Describe enterLocalScope method here.
 void execute()
          Execute the entire code of the program.
 void execute(int progbase)
          Execute code of the program, starting at a given program counter.
 void exitLocalScope()
          Describe exitLocalScope method here.
 double getData(int address)
          Describe getData method here.
 int getProgramBase()
          Describe getProgramBase method here.
 void globalScope()
          Describe globalScope method here.
 void initMathConstants()
          Describe initMathConstants method here.
 boolean isConstant(java.lang.String id)
          Describe isConstant method here.
 StackMachine.SymbolTableEntry lookup(java.lang.String name)
          Lookup symbol in a symbol table.
 java.lang.Object peek()
          Describe peek method here.
 double peekDouble()
          Describe peekDouble method here.
 int peekInt()
          Describe peekInt method here.
 java.lang.Object pop()
          Describe pop method here.
 double popDouble()
          Describe popDouble method here.
 int popInt()
          Describe popInt method here.
 int popReturn()
          Describe popReturn method here.
 void pushDouble(double x)
          Describe pushDouble method here.
 void pushInstruction(StackMachine.Instruction i)
          Add an instruction at the end of the program
 void pushInstruction(StackMachine.Instruction i, java.lang.String name, int nargs)
          Push instruction with arity check
 void pushInt(int x)
          Describe pushInt method here.
 void pushReturn(int location)
          Describe pushReturn method here.
 java.lang.Object removeSymbol(java.lang.String id)
          Remove a symbol from the current scope.
 void renameSymbol(java.lang.String old, java.lang.String id)
          Rename a global symbol.
 boolean scopeIsLocal()
          Describe scopeIsLocal method here.
 void setInstructionAt(StackMachine.Instruction i, int location)
          Sets an instruction at a given location in the program
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackMachine

public StackMachine()
Creates a new StackMachine instance.

Method Detail

getProgramBase

public final int getProgramBase()
Describe getProgramBase method here.

Returns:
The program counter

scopeIsLocal

public final boolean scopeIsLocal()
Describe scopeIsLocal method here.

Returns:
a boolean value

enterLocalScope

public final void enterLocalScope()
                           throws ParseException
Describe enterLocalScope method here.

Throws:
ParseException - if an error occurs

exitLocalScope

public final void exitLocalScope()
                          throws ParseException
Describe exitLocalScope method here.

Throws:
ParseException - if an error occurs

globalScope

public final void globalScope()
Describe globalScope method here.


initMathConstants

public final void initMathConstants()
Describe initMathConstants method here.


clearProgram

public final void clearProgram()
Describe clearProgram method here.


clearProgram

public final void clearProgram(int beg)
Describe clearProgram method here.

Parameters:
beg - an int value

clearStack

public final void clearStack()
Describe clearStack method here.


clearReturnStack

public final void clearReturnStack()
Describe clearReturnStack method here.


clearGlobalSymbolTable

public final void clearGlobalSymbolTable()
Describe clearGlobalSymbolTable method here.


clearLocalSymbolTable

public final void clearLocalSymbolTable()
Describe clearLocalSymbolTable method here.


clear

public final void clear()
Describe clear method here.


dumpStack

public final void dumpStack()
Describe dumpStack method here.


isConstant

public final boolean isConstant(java.lang.String id)
Describe isConstant method here.

Parameters:
id - a String value
Returns:
a boolean value

renameSymbol

public final void renameSymbol(java.lang.String old,
                               java.lang.String id)
                        throws ParseException
Rename a global symbol.

Parameters:
old - Old symbol name.
id - New symbol name.
Throws:
ParseException - if an error occurs

createVariable

public final StackMachine.Variable createVariable(java.lang.String id)
Create a new global variable.

Parameters:
id - The name of the variable
Returns:
a Variable value

createVariable

public final StackMachine.Variable createVariable(java.lang.String id,
                                                  double value)
Create a new global variable.

Parameters:
id - The name of the variable
value - a double value
Returns:
a Variable value

removeSymbol

public final java.lang.Object removeSymbol(java.lang.String id)
Remove a symbol from the current scope.

Parameters:
id - The name of the symbol.
Returns:
The previous entry in the symbol table.

createConstant

public final void createConstant(java.lang.String id,
                                 double value)
Create a new constant and place it in the global symbol table. Directly set a value of a variable.

Parameters:
id - The name of the constant.
value - The value of the constant.

createFunction

public final void createFunction(java.lang.String id,
                                 int progbase,
                                 int argbase,
                                 int nargs)
Describe createFunction method here.

Parameters:
id - a String value
progbase - an int value
argbase - an int value
nargs - an int value

lookup

public StackMachine.SymbolTableEntry lookup(java.lang.String name)
Lookup symbol in a symbol table.

Parameters:
name - Name of symbol to be looked up
Returns:
Address (index) or the data associated with the name

getData

public final double getData(int address)
                     throws ParseException
Describe getData method here.

Parameters:
address - an int value
Returns:
a double value
Throws:
ParseException - if an error occurs

pushInstruction

public final void pushInstruction(StackMachine.Instruction i)
Add an instruction at the end of the program

Parameters:
i - The instruction

setInstructionAt

public final void setInstructionAt(StackMachine.Instruction i,
                                   int location)
Sets an instruction at a given location in the program

Parameters:
i - The instruction
location - an int value

allocateVariable

public final int allocateVariable()
Add a new uninitialized variable.

Returns:
The address of the new variable.

clearData

public final void clearData()
Describe clearData method here.


allocateVariable

public final int allocateVariable(double value)
Add a new initialized variable.

Parameters:
value - a double value
Returns:
Pointer to the variable.

assign

public final void assign(int address,
                         double value)
                  throws ParseException
Assign value to a variable.

Parameters:
address - The address of the variable.
value - The value to be assigned.
Throws:
ParseException - if an error occurs

pushInstruction

public final void pushInstruction(StackMachine.Instruction i,
                                  java.lang.String name,
                                  int nargs)
                           throws ParseException
Push instruction with arity check

Parameters:
i - The instruction.
name - The name of the function to be reported if arity and the number of arguments don't match
nargs - The number of arguments.
Throws:
ParseException - if an error occurs

pop

public final java.lang.Object pop()
                           throws ParseException
Describe pop method here.

Returns:
an Object value
Throws:
ParseException - if an error occurs

popReturn

public final int popReturn()
                    throws ParseException
Describe popReturn method here.

Returns:
an int value
Throws:
ParseException - if an error occurs

pushReturn

public final void pushReturn(int location)
Describe pushReturn method here.

Parameters:
location - an int value

peek

public final java.lang.Object peek()
                            throws ParseException
Describe peek method here.

Returns:
an Object value
Throws:
ParseException - if an error occurs

popInt

public final int popInt()
                 throws ParseException
Describe popInt method here.

Returns:
an int value
Throws:
ParseException - if an error occurs

peekInt

public final int peekInt()
                  throws ParseException
Describe peekInt method here.

Returns:
an int value
Throws:
ParseException - if an error occurs

peekDouble

public final double peekDouble()
                        throws ParseException
Describe peekDouble method here.

Returns:
a double value
Throws:
ParseException - if an error occurs

popDouble

public final double popDouble()
                       throws ParseException
Describe popDouble method here.

Returns:
a double value
Throws:
ParseException - if an error occurs

pushInt

public final void pushInt(int x)
Describe pushInt method here.

Parameters:
x - an int value

pushDouble

public final void pushDouble(double x)
Describe pushDouble method here.

Parameters:
x - a double value

execute

public final void execute(int progbase)
                   throws ParseException
Execute code of the program, starting at a given program counter.

Parameters:
progbase - an int value
Throws:
ParseException - if an error occurs

execute

public final void execute()
                   throws ParseException
Execute the entire code of the program.

Throws:
ParseException - if an error occurs



This page last modified Sun Sep 12 12:29:59 2004
Questions? Comments? Please send feedback to jason howald