cgp.runtime
Class ActorType

java.lang.Object
  |
  +--cgp.runtime.Type
        |
        +--cgp.runtime.LambdaType
              |
              +--cgp.runtime.ActorType

public class ActorType
extends LambdaType


Field Summary
private static java.lang.String ANON_NAME
           
private  java.util.LinkedList runList
           
private  ScopeStack scopes
           
private static java.lang.String SELF_NAME
           
 
Fields inherited from class cgp.runtime.LambdaType
body, defGraph, formals, name
 
Fields inherited from class cgp.runtime.Type
kbStack, scopeStack, type
 
Constructor Summary
ActorType(GraphType body)
          Invoke this constructor when defining an anonymous actor, typically for direct activation of a graph (e.g.
ActorType(java.lang.String name, FormalParameter[] formals, GraphType body)
          Invoke this constructor when defining a named actor via an "actor" type definition.
ActorType(java.lang.String name, FormalParameter[] formals, GraphType defGraph, notio.Graph body)
          Invoke this constructor when copy()ing.
 
Method Summary
 void bindParametersToSourceConcepts(Type[] actuals)
          Mutate source concept designators with actuals, by argument order.
private  notio.Actor[] collectSubActors()
          Collect sub-actors in this actor.
 LambdaType copy()
          Copy this actor such that a clone of the defining graph exists for the purpose of actor execution.
 SubActorInfo getNextSubActor()
          Return the sub-actor (actor or function) which is next ready to to be executed by virtue of having all input concept designators bound to pCG literals.
 ListType getSinkconcepts()
          Getter and setter methods for attributes.
static ConceptType[] getSinks(GraphType body)
          The sink arguments of an actor graph are those which take output from one (unless conflicting, then > 1) sub-actor and provide input to no sub-actor.
 ListType getSourceconcepts()
           
static ConceptType[] getSources(GraphType body)
          The source arguments of an actor graph are those which provide input into one or more sub-actors but are outputs of no sub-actor.
private static java.util.Hashtable getSubActorIOCounts(GraphType body)
          Return a hash containing the per sub-actor count of input and output concepts in the supplied graph.
 void initActorExecution()
          Store each sub-actor in a run list.
 boolean isAnonymous()
          Is this an anonymous actor? This will be the case when the constructor whose signature is ActorType(GraphType) is used.
 boolean isExecutable()
          Is this actor instance still executable?
 void studyGraph()
          1.
 
Methods inherited from class cgp.runtime.LambdaType
bindParameters, getBody, getDefgraph, getFormals, getId, getName, toString
 
Methods inherited from class cgp.runtime.Type
addOp, andOp, divideOp, eqOp, geOp, getAttr, getKBStack, getNthOp, getScopeStack, getType, gtOp, invokeMemberFunc, isOp, leOp, ltOp, modulusOp, multiplyOp, negateOp, neOp, notOp, operationError, orOp, setAttr, setKBStack, setNthOp, setScopeStack, setType, subtractOp
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

SELF_NAME

private static java.lang.String SELF_NAME

ANON_NAME

private static java.lang.String ANON_NAME

scopes

private ScopeStack scopes

runList

private java.util.LinkedList runList
Constructor Detail

ActorType

public ActorType(java.lang.String name,
                 FormalParameter[] formals,
                 GraphType body)
Invoke this constructor when defining a named actor via an "actor" type definition.

ActorType

public ActorType(GraphType body)
Invoke this constructor when defining an anonymous actor, typically for direct activation of a graph (e.g. in a process).

ActorType

public ActorType(java.lang.String name,
                 FormalParameter[] formals,
                 GraphType defGraph,
                 notio.Graph body)
Invoke this constructor when copy()ing.
Method Detail

isAnonymous

public boolean isAnonymous()
Is this an anonymous actor? This will be the case when the constructor whose signature is ActorType(GraphType) is used.

bindParametersToSourceConcepts

public void bindParametersToSourceConcepts(Type[] actuals)
Mutate source concept designators with actuals, by argument order. This could be used when there is no actor type definition, and source concept designators are already bound, so name to actual argument mapping is impossible, e.g. in the case of a recursive, anonymous actor. Indeed, this would seem to be the *only* case. It is assumed that a copy of the defining graph is being used when binding.

studyGraph

public void studyGraph()
1. Identify source, intermediate, and sink concepts. Also look for conflicting concepts and raise an exception if found.

2. Check that each formal parameter corresponds to >= 1 designators of that name.

3. Determine whether sub-actors exist in this graph, each of which must correspond to a user-defined function or actor.

Note: only does 3. currently.


copy

public LambdaType copy()
Copy this actor such that a clone of the defining graph exists for the purpose of actor execution.
Overrides:
copy in class LambdaType

initActorExecution

public void initActorExecution()
Store each sub-actor in a run list.

isExecutable

public boolean isExecutable()
Is this actor instance still executable?

getNextSubActor

public SubActorInfo getNextSubActor()
Return the sub-actor (actor or function) which is next ready to to be executed by virtue of having all input concept designators bound to pCG literals. Note that there may be multiple sub-actors in the ready state simultaneously, but the first encountered on the run-list is arbitrarily chosen. A requirement therefore is that sub-actor execution must be referentially transparent. Note that once chosen for execution, a sub-actor becomes inelligible for execution again. Returns null if no sub-actors can be executed. Pre-conditions: - studyGraph() has been invoked so we know a given sub-actor maps to an underlying function/actor. - This method should not be invoked unless isExecutable() returns true.

getSubActorIOCounts

private static java.util.Hashtable getSubActorIOCounts(GraphType body)
Return a hash containing the per sub-actor count of input and output concepts in the supplied graph. These counts can then be used to determine sink, source, intermediate, or conflicting concept nodes. See [Lukose & Mineau 1998] or my thesis for a description of each.

getSinks

public static ConceptType[] getSinks(GraphType body)
The sink arguments of an actor graph are those which take output from one (unless conflicting, then > 1) sub-actor and provide input to no sub-actor. Note that we are interested in the final outputs from the actor, not intermediate outputs.

getSources

public static ConceptType[] getSources(GraphType body)
The source arguments of an actor graph are those which provide input into one or more sub-actors but are outputs of no sub-actor.

collectSubActors

private notio.Actor[] collectSubActors()
Collect sub-actors in this actor. Preconditions: - The graph has already been studied via studyGraph() and found to contain valid sub-actors.

getSinkconcepts

public ListType getSinkconcepts()
Getter and setter methods for attributes.

getSourceconcepts

public ListType getSourceconcepts()