org.quasiliteral.quasiterm
Class QDollarHole

java.lang.Object
  |
  +--org.quasiliteral.quasiterm.QAstroArg
        |
        +--org.quasiliteral.quasiterm.QAstro
              |
              +--org.quasiliteral.quasiterm.QHole
                    |
                    +--org.quasiliteral.quasiterm.QDollarHole
All Implemented Interfaces:
Astro, AstroArg, Marker, MatchMaker, PassByConstruction, Persistent, Selfless, Serializable, ValueMaker

public class QDollarHole
extends QHole

Untamed: A dollar hole of a quasi-literal term expression is filled in with a substitution arg.

As a ValueMaker, this evaluates to the corresponding substitution arg, given that it meets all encoded conditions (see QHole).

As a MatchMaker, this compares ("<=>") a specimen term against the substitution argument. The substitution argument must again meet all encoded conditions.

Author:
Mark S. Miller
See Also:
Serialized Form

Field Summary
static StaticMaker QDollarHoleMaker
          Enabled:
(package private) static long serialVersionUID
           
 
Fields inherited from class org.quasiliteral.quasiterm.QHole
myHoleNum, myIsFunctorHole, myOptTag
 
Fields inherited from class org.quasiliteral.quasiterm.QAstroArg
EListGuard, EMPTY_INDEX, myBuilder, myOptSpan
 
Fields inherited from interface org.erights.e.elib.tables.Selfless
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.PassByConstruction
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Constructor Summary
(package private) QDollarHole(AstroBuilder builder, AstroTag optTag, int holeNum, boolean isFunctorHole, SourceSpan optSpan)
          Makes a hole that is filled in by a substitution arg.
 
Method Summary
(package private)  QAstro asFunctor()
          Returns a variant of this Astro that may serve as a functor of a QTerm.
(package private)  QHole asTagged(Astro ident)
           
(package private)  void endShape(FlexList optBindings, int[] prefix, int shape)
          Do nothing.
 Object[] getSpreadUncall()
          Enabled: Uses 'QDollarHoleMaker(myBuilder, myOptTag, myHoleNum, myIsFunctorHole, myOptSpan)'
 int matchBindSlice(ConstList args, ConstList specimenList, FlexList bindings, int[] index)
          Enabled: This compares ("<=>") the substitution arg at [myHoleNum]+index against the specimenList[0].
 void prettyPrintOn(TextWriter out)
          Enabled:
 AstroArg qbuild(QuasiBuilder qbuilder)
          Enabled:
(package private)  int startShape(ConstList args, FlexList optBindings, int[] prefix, int shapeSoFar)
          If the substitution arg at [myHoleHum]+prefix is actually a list for further indexing, what's the size of that list?
 ConstList substSlice(ConstList args, int[] index)
          Enabled: This extracts the substitution arg at [myHoleNum]+index, requires that it matches, and returns a singleton list containing that arg (which should be a literal term).
 
Methods inherited from class org.quasiliteral.quasiterm.QHole
getArgs, getHeight, getOptData, getTag, multiGet, multiPut, optCoerce, withArgs, withoutArgs
 
Methods inherited from class org.quasiliteral.quasiterm.QAstro
build, getOptArgData, getOptArgData, getOptArgString, getOptString, getOptTagCode, matchBind, matchBind, substitute
 
Methods inherited from class org.quasiliteral.quasiterm.QAstroArg
__printOn, asText, getOptSpan, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.quasiliteral.astro.AstroArg
getOptSpan
 

Field Detail

serialVersionUID

static final long serialVersionUID

QDollarHoleMaker

public static final StaticMaker QDollarHoleMaker
Enabled:

Constructor Detail

QDollarHole

QDollarHole(AstroBuilder builder,
            AstroTag optTag,
            int holeNum,
            boolean isFunctorHole,
            SourceSpan optSpan)
Makes a hole that is filled in by a substitution arg.

The invariants of a QDollarHole are not checked here, but rather are enforced by the callers in this class and in QTermBuilder.

For the meanings of the parameters, see the QHole constructor, which has the same parameters.

Method Detail

getSpreadUncall

public Object[] getSpreadUncall()
Enabled: Uses 'QDollarHoleMaker(myBuilder, myOptTag, myHoleNum, myIsFunctorHole, myOptSpan)'


qbuild

public AstroArg qbuild(QuasiBuilder qbuilder)
Enabled:

Specified by:
qbuild in class QAstroArg

startShape

int startShape(ConstList args,
               FlexList optBindings,
               int[] prefix,
               int shapeSoFar)
If the substitution arg at [myHoleHum]+prefix is actually a list for further indexing, what's the size of that list?

If it's not a list, it could still act as a list by repetition, but then it's of indeterminate size, so just return shapeSoFar. If it is a list, then if shapeSoFar has already been determined (ie, not -1), then require these to agree.

Specified by:
startShape in class QAstroArg

endShape

void endShape(FlexList optBindings,
              int[] prefix,
              int shape)
Do nothing.

Specified by:
endShape in class QAstroArg

substSlice

public ConstList substSlice(ConstList args,
                            int[] index)
Enabled: This extracts the substitution arg at [myHoleNum]+index, requires that it matches, and returns a singleton list containing that arg (which should be a literal term).

Specified by:
substSlice in class QAstroArg
Parameters:
index - Further indexes after a hole's hole-num. For example, If a dollar-hole's hole-num is 3 and index is [4,5], then the dollar-hole would evaluate to args[3][4][5].
Returns:
:(ConstList of(Astro))

matchBindSlice

public int matchBindSlice(ConstList args,
                          ConstList specimenList,
                          FlexList bindings,
                          int[] index)
Enabled: This compares ("<=>") the substitution arg at [myHoleNum]+index against the specimenList[0].

This first ensures that the substitution arg meets our own constraints.

Specified by:
matchBindSlice in class QAstroArg
Parameters:
args - See the doc on 'args' in #substitute(Object[], String)
specimenList - :(ConstList of(Astro))
bindings - Like 'args', but by extraction from specimen
index - Further indexes after a hole's hole-num. For example, If a dollar-hole's hole-num is 3 and index is [4,5], then the dollar-hole would access args[3][4][5]. Similarly, an at-hole with hole-num 3 would store into bindings[3][4][5].
Returns:
-1 or 1, depending on whether they match.

asTagged

QHole asTagged(Astro ident)
Specified by:
asTagged in class QHole

asFunctor

QAstro asFunctor()
Description copied from class: QAstro
Returns a variant of this Astro that may serve as a functor of a QTerm.

If this Astro (or derivatives) should not be used as a functor, then this operation should throw.

Specified by:
asFunctor in class QAstro

prettyPrintOn

public void prettyPrintOn(TextWriter out)
                   throws IOException
Enabled:

Specified by:
prettyPrintOn in class QAstroArg
IOException


comments?