org.hecl
Class CodeThing

java.lang.Object
  extended by org.hecl.CodeThing
All Implemented Interfaces:
RealThing

public class CodeThing
extends java.lang.Object
implements RealThing

The CodeThing class implements a chunk of "compiled" code including multiple "Stanzas", or individual commands.

Version:
1.0
Author:
David N. Welton

Field Summary
 boolean marksubst
           
 
Method Summary
 void addStanza(Interp interp, Thing[] argv, int lineno)
          The addStanza method adds a new command and its arguments.
 RealThing deepcopy()
          CodeThing's deepcopy method makes a copy of all the stanzas, which in turn copy all their objects.
protected static Thing doCodeSubst(Interp interp, Thing thing)
          doCodeSubst takes a code Thing and runs it, returning the result.
protected static Thing doGroupSubst(Interp interp, Thing thing)
          doGroupSubst runs substitutions on 'groups' of things, such as "foo $foo [foo]".
protected static Thing doSubstSubst(Interp interp, Thing thing)
          doSubstSubst runs substitutions on things of the SubstThing type, which means $foo or &foo in Hecl.
static CodeThing get(Interp interp, Thing thing)
          get returns a CodeThing object from any kind of Thing - or returns an error.
 java.lang.String getStringRep()
          The getStringRep method returns a String representation of the commands it represents.
 Thing run(Interp interp)
          The run method runs the CodeThing.
 java.lang.String thingclass()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

marksubst

public boolean marksubst
Method Detail

thingclass

public java.lang.String thingclass()
Specified by:
thingclass in interface RealThing

get

public static CodeThing get(Interp interp,
                            Thing thing)
                     throws HeclException
get returns a CodeThing object from any kind of Thing - or returns an error.

Parameters:
interp - an Interp value
thing - a Thing value
Returns:
a CodeThing value
Throws:
HeclException - if an error occurs

deepcopy

public RealThing deepcopy()
                   throws HeclException
CodeThing's deepcopy method makes a copy of all the stanzas, which in turn copy all their objects.

Specified by:
deepcopy in interface RealThing
Returns:
a RealThing value
Throws:
HeclException - if an error occurs

doCodeSubst

protected static Thing doCodeSubst(Interp interp,
                                   Thing thing)
                            throws HeclException
doCodeSubst takes a code Thing and runs it, returning the result. This is used for substitution in situations like this: "foo [bar] baz", where the substitution needs to be run every time, but the block can't be broken up. doCodeSubst operates on the [bar] word in the above case.

Parameters:
interp - an Interp value
thing - a Thing value
Returns:
a Thing value
Throws:
HeclException - if an error occurs

doSubstSubst

protected static Thing doSubstSubst(Interp interp,
                                    Thing thing)
                             throws HeclException
doSubstSubst runs substitutions on things of the SubstThing type, which means $foo or &foo in Hecl.

Parameters:
interp - an Interp value
thing - a Thing value
Returns:
a Thing value
Throws:
HeclException - if an error occurs

doGroupSubst

protected static Thing doGroupSubst(Interp interp,
                                    Thing thing)
                             throws HeclException
doGroupSubst runs substitutions on 'groups' of things, such as "foo $foo [foo]". The group can't be broken up, so it needs to be substituted together by subst'ing the individual components.

Parameters:
interp - an Interp value
thing - a Thing value
Returns:
a Thing value
Throws:
HeclException - if an error occurs

addStanza

public void addStanza(Interp interp,
                      Thing[] argv,
                      int lineno)
The addStanza method adds a new command and its arguments.

Parameters:
interp - Interp value
argv - Thing[] value

run

public Thing run(Interp interp)
          throws HeclException
The run method runs the CodeThing.

Parameters:
interp - Interp value
Throws:
HeclException - if an error occurs

getStringRep

public java.lang.String getStringRep()
The getStringRep method returns a String representation of the commands it represents.

Specified by:
getStringRep in interface RealThing
Returns:
a String value.