com.veromodo.tempo.sem
Class Environment

java.lang.Object
  extended by com.veromodo.tempo.sem.Environment

public class Environment
extends java.lang.Object


Constructor Summary
Environment(ErrorLog log, Tracker track)
           
 
Method Summary
 Descriptor addAnonymous(Resource n)
           
 Descriptor addAutoBasic(Resource n, CollectionVocabRef i, TypeBasicAutomaton t)
           
 Descriptor addAutoComponentMapToParent(Resource n, java.lang.String name, AutomatonInstanceDescriptor ad, TypeMap t)
           
 Descriptor addAutoComponentToParent(Resource n, java.lang.String name, AutomatonInstanceDescriptor ad, Type t)
           
 Descriptor addAutoComposite(Resource n, CollectionVocabRef i, TypeCompositeAutomaton t)
           
 Descriptor addAutoFormal(Resource n, Type t)
           
 Descriptor addAutoInstance(Resource n, java.lang.String name, AutomatonDescriptor ad, Type t)
           
 Descriptor addChooseLocal(Resource n, Type t)
           
 Descriptor addComponentFormal(Resource n, Type t)
           
 void addDelegatesOf(IScope s)
           
 void addDeligate(IScope s)
           
 Descriptor addEnumValue(java.lang.String value, TypeEnumValue te, Extent xt)
           
 Descriptor addField(java.lang.String lex, Type ft, Extent extent)
           
 Descriptor addForLoopLocal(Resource n, Type t)
           
 Descriptor addFunction(Resource n, Type t)
           
 Descriptor addFunction(java.lang.String name, Type t, Extent e)
           
 Descriptor addFunctionGlobal(java.lang.String name, Type t, Extent e)
           
 Descriptor addHiddenLocal(Resource n, Type t)
           
 Descriptor addInfixOp(Resource n, Type t)
           
 Descriptor addLetFunction(Resource n, Type t)
           
 Descriptor addLetFunctionFormal(Resource n, Type t)
           
 Descriptor addMixOp(java.lang.String name, boolean before, int between, boolean after, Type _tty, Extent e)
           
 Descriptor addPrefixOp(Resource n, Type t)
           
 Descriptor addProofVar(Resource n, Type t)
           
 Descriptor addQuantifiedVar(Resource n, Type t)
           
 void addRequirement(java.lang.String tn, int ta, Vocabulary voc)
           
 Descriptor addScheduleState(Resource n, Type t)
           
 Descriptor addSigFormal(Resource n, Type t)
           
 Descriptor addSignature(ResourceGenre r, Type t)
           
 Descriptor addState(Resource n, Type t)
           
 Descriptor addSuffixOp(Resource n, Type t)
           
 Descriptor addSumTag(java.lang.String lex, Type sft, Extent extent)
           
 Descriptor addTaskLocal(Resource n, Type t)
           
 Descriptor addTrajectory(Resource n, Type t)
           
 TransitionDescriptor addTransition(ResourceGenre r, Type t)
           
 Descriptor addTransLocal(Resource n, Type t)
           
 Descriptor addType(Resource r, Type t)
           
 Descriptor addType(java.lang.String name, Type t, Extent e)
           
 Descriptor addTypeGlobal(java.lang.String name, Type t, Extent e)
           
 Descriptor addUnQuantifiedActual(Resource n, Type t)
           
 VocabularyDescriptor addVocabulary(java.lang.String name, Extent e, Vocabulary v)
           
 java.util.Collection<Descriptor> collectDescriptors(DescriptorPredicate p)
           
 java.util.HashSet<Type> collectTypes(DescriptorPredicate p)
           
 java.util.HashSet<Type> collectTypes(java.util.EnumSet<Descriptor.Kind> mbrOf)
           
 java.util.HashSet<Type> collectTypes(java.lang.String op)
           
 java.util.HashSet<Type> collectTypes(java.lang.String op, DescriptorPredicate p)
           
 java.util.HashSet<Type> collectTypes(java.lang.String op, java.util.EnumSet<Descriptor.Kind> mbrOf)
           
 Vocabulary createVocabulary(java.lang.String vName)
          This method creates a brand new, empty vocabulary.
 SetOfType cross(SetOfType s1, SetOfType s2)
          Computes the cross product between two sets of types.
 void debug(java.lang.String msg, Extent e)
           
 Type genersizeType(Type ty)
          Deprecated. types are genersized automatically when inserted into a descriptor
 AutomatonComponentDescriptor getAutomatonComponentSymbol(java.lang.String name)
           
 AutomatonInstanceDescriptor getAutomatonInstanceSymbol(java.lang.String name)
           
 AutomatonDescriptor getAutomatonSymbol(java.lang.String name)
          Returns a description for an automaton with a given name.
 Type getBool()
           
 Type getError()
           
 Descriptor getFunctionLetSymbol(java.lang.String name, Type t)
           
 Descriptor getFunctionSymbol(java.lang.String name, Type t)
           
 SigInDescriptor getInputSymbol(java.lang.String name)
           
 SigInternalDescriptor getInternalSymbol(java.lang.String name)
           
 SigOutDescriptor getOutputSymbol(java.lang.String name)
           
 SignatureDescriptor getSignatureSymbol(java.lang.String name)
           
 Tracker getTracker()
           
 Descriptor getTypeSymbol(java.lang.String name)
           
 Descriptor getTypeSymbol(java.lang.String name, int arity, Type[] at)
          This method attempts to retrieve a symbol (of specific arity) and may auto-load vocabularies based on the requirement table.
 Descriptor getViod()
           
 VocabularyDescriptor getVocabularySymbol(java.lang.String name)
           
 boolean hasVocabulary(java.lang.String vName)
          Returns true if and only if a vocabulary of that name is loaded.
 void importVocabulary(Vocabulary voc, boolean fromImport)
          This method registers the specified vocabulary as a delegate scope underneath either the current or the global scope
 void info(java.lang.String msg, Extent e)
           
 Vocabulary instantiate(Vocabulary voc, java.util.ArrayList<Type> actuals)
           
 IScope openRootScope(java.lang.String name)
           
 IScope openScope(java.lang.String name)
           
 IScope openTopScope(java.lang.String name)
           
 IImportAdder popImportContext()
           
 java.lang.String popLoadingFile()
           
 IScope popScope()
           
 TypeParameterContext popTypeContext()
           
 void printCalls()
           
 IImportAdder pushImportContext(IImportAdder ic)
           
 boolean pushLoadingFile(java.lang.String filePath)
           
 TypeParameterContext pushTypeContext(TypeParameterContext tp)
           
 void reOpenScope(IScope s)
           
 void revertScope()
          revertScope is used in conjunction with reOpenScope.
 void setFileLocation(java.lang.String fLoc)
           
 void setRootTracker(Tracker tracker)
           
 void track(ASTNode root)
           
 Vocabulary tryLoadVocabulary(java.lang.String vName, int arity)
           
 Vocabulary vocabForName(java.lang.String vName)
          The method returns the vocabulary representation for a given name.
 Vocabulary vocabForType(java.lang.String tName, int arity)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Environment

public Environment(ErrorLog log,
                   Tracker track)
Method Detail

printCalls

public void printCalls()

addRequirement

public void addRequirement(java.lang.String tn,
                           int ta,
                           Vocabulary voc)

pushLoadingFile

public boolean pushLoadingFile(java.lang.String filePath)

popLoadingFile

public java.lang.String popLoadingFile()

setFileLocation

public void setFileLocation(java.lang.String fLoc)

genersizeType

public Type genersizeType(Type ty)
Deprecated. types are genersized automatically when inserted into a descriptor

Idealy this method should be removed currently it is only required by ComponentAnalyze and it's deligate class ActualCollector

Parameters:
ty -
Returns:

cross

public SetOfType cross(SetOfType s1,
                       SetOfType s2)
Computes the cross product between two sets of types. The receiver and s cannot be empty. Typically, the receiver is a set of tuple types. The receiver could be { <> }, i.e., a set with an empty tuple. Note that the tuples are flattened so that repeated crossing does not yield nested tuples.

Parameters:
s2 - The set to cross with.
Returns:
this x s

addType

public Descriptor addType(java.lang.String name,
                          Type t,
                          Extent e)

addType

public Descriptor addType(Resource r,
                          Type t)

addTypeGlobal

public Descriptor addTypeGlobal(java.lang.String name,
                                Type t,
                                Extent e)

addVocabulary

public VocabularyDescriptor addVocabulary(java.lang.String name,
                                          Extent e,
                                          Vocabulary v)

addInfixOp

public Descriptor addInfixOp(Resource n,
                             Type t)

addPrefixOp

public Descriptor addPrefixOp(Resource n,
                              Type t)

addSuffixOp

public Descriptor addSuffixOp(Resource n,
                              Type t)

addMixOp

public Descriptor addMixOp(java.lang.String name,
                           boolean before,
                           int between,
                           boolean after,
                           Type _tty,
                           Extent e)

addFunction

public Descriptor addFunction(java.lang.String name,
                              Type t,
                              Extent e)

addFunction

public Descriptor addFunction(Resource n,
                              Type t)

addLetFunction

public Descriptor addLetFunction(Resource n,
                                 Type t)

addLetFunctionFormal

public Descriptor addLetFunctionFormal(Resource n,
                                       Type t)

addState

public Descriptor addState(Resource n,
                           Type t)

addScheduleState

public Descriptor addScheduleState(Resource n,
                                   Type t)

addFunctionGlobal

public Descriptor addFunctionGlobal(java.lang.String name,
                                    Type t,
                                    Extent e)

addEnumValue

public Descriptor addEnumValue(java.lang.String value,
                               TypeEnumValue te,
                               Extent xt)

addSignature

public Descriptor addSignature(ResourceGenre r,
                               Type t)

addSigFormal

public Descriptor addSigFormal(Resource n,
                               Type t)

addTransition

public TransitionDescriptor addTransition(ResourceGenre r,
                                          Type t)

addTransLocal

public Descriptor addTransLocal(Resource n,
                                Type t)

addHiddenLocal

public Descriptor addHiddenLocal(Resource n,
                                 Type t)

addChooseLocal

public Descriptor addChooseLocal(Resource n,
                                 Type t)

addTrajectory

public Descriptor addTrajectory(Resource n,
                                Type t)

addTaskLocal

public Descriptor addTaskLocal(Resource n,
                               Type t)

addQuantifiedVar

public Descriptor addQuantifiedVar(Resource n,
                                   Type t)

addProofVar

public Descriptor addProofVar(Resource n,
                              Type t)

addForLoopLocal

public Descriptor addForLoopLocal(Resource n,
                                  Type t)

addAutoBasic

public Descriptor addAutoBasic(Resource n,
                               CollectionVocabRef i,
                               TypeBasicAutomaton t)

addAutoFormal

public Descriptor addAutoFormal(Resource n,
                                Type t)

addAutoComposite

public Descriptor addAutoComposite(Resource n,
                                   CollectionVocabRef i,
                                   TypeCompositeAutomaton t)

addComponentFormal

public Descriptor addComponentFormal(Resource n,
                                     Type t)

addAutoInstance

public Descriptor addAutoInstance(Resource n,
                                  java.lang.String name,
                                  AutomatonDescriptor ad,
                                  Type t)

addAutoComponentToParent

public Descriptor addAutoComponentToParent(Resource n,
                                           java.lang.String name,
                                           AutomatonInstanceDescriptor ad,
                                           Type t)

addAutoComponentMapToParent

public Descriptor addAutoComponentMapToParent(Resource n,
                                              java.lang.String name,
                                              AutomatonInstanceDescriptor ad,
                                              TypeMap t)

addField

public Descriptor addField(java.lang.String lex,
                           Type ft,
                           Extent extent)

addSumTag

public Descriptor addSumTag(java.lang.String lex,
                            Type sft,
                            Extent extent)

addUnQuantifiedActual

public Descriptor addUnQuantifiedActual(Resource n,
                                        Type t)

addAnonymous

public Descriptor addAnonymous(Resource n)

getBool

public Type getBool()

getError

public Type getError()

getViod

public Descriptor getViod()

getTypeSymbol

public Descriptor getTypeSymbol(java.lang.String name)

getTypeSymbol

public Descriptor getTypeSymbol(java.lang.String name,
                                int arity,
                                Type[] at)
This method attempts to retrieve a symbol (of specific arity) and may auto-load vocabularies based on the requirement table. The method first attempts to find the symbol in the symbol table. If successful, it returns the descriptor. If not, it attempts to load a vocabulary (based on requirement table). If the symbol is parametric and the vocabulary was loaded, it can be instantiated and finally imported. Then we loop around to attempts another lookup in the symbol table. (at most 2 attempts are done).

Parameters:
name - The name of the type symbol to load
arity - The arity of the type symbol (e.g. Seq[Int] : name=Seq and arity=1
at - The actual types to use for the generic type instantiation. E.g. Seq[Int] is an instantiation of Seq[T] with Int.
Returns:
The type object requested, or null if this is an unknown type.

getVocabularySymbol

public VocabularyDescriptor getVocabularySymbol(java.lang.String name)

getSignatureSymbol

public SignatureDescriptor getSignatureSymbol(java.lang.String name)

getInternalSymbol

public SigInternalDescriptor getInternalSymbol(java.lang.String name)

getInputSymbol

public SigInDescriptor getInputSymbol(java.lang.String name)

getOutputSymbol

public SigOutDescriptor getOutputSymbol(java.lang.String name)

getFunctionSymbol

public Descriptor getFunctionSymbol(java.lang.String name,
                                    Type t)
Returns:
null if no such Descriptor exists

getFunctionLetSymbol

public Descriptor getFunctionLetSymbol(java.lang.String name,
                                       Type t)
Returns:
null if no such Descriptor exists

getAutomatonSymbol

public AutomatonDescriptor getAutomatonSymbol(java.lang.String name)
Returns a description for an automaton with a given name. Returns null if there is no automaton with the given name.


getAutomatonInstanceSymbol

public AutomatonInstanceDescriptor getAutomatonInstanceSymbol(java.lang.String name)

getAutomatonComponentSymbol

public AutomatonComponentDescriptor getAutomatonComponentSymbol(java.lang.String name)

collectDescriptors

public java.util.Collection<Descriptor> collectDescriptors(DescriptorPredicate p)

openTopScope

public IScope openTopScope(java.lang.String name)

pushImportContext

public IImportAdder pushImportContext(IImportAdder ic)

popImportContext

public IImportAdder popImportContext()

pushTypeContext

public TypeParameterContext pushTypeContext(TypeParameterContext tp)

popTypeContext

public TypeParameterContext popTypeContext()

openScope

public IScope openScope(java.lang.String name)

openRootScope

public IScope openRootScope(java.lang.String name)

popScope

public IScope popScope()

addDelegatesOf

public void addDelegatesOf(IScope s)

addDeligate

public void addDeligate(IScope s)

reOpenScope

public void reOpenScope(IScope s)

revertScope

public void revertScope()
revertScope is used in conjunction with reOpenScope. It is meant to restore the scope that was current before the latest reOpenScope call took place.


getTracker

public Tracker getTracker()

setRootTracker

public void setRootTracker(Tracker tracker)

debug

public void debug(java.lang.String msg,
                  Extent e)

info

public void info(java.lang.String msg,
                 Extent e)

track

public void track(ASTNode root)

collectTypes

public java.util.HashSet<Type> collectTypes(java.lang.String op)

collectTypes

public java.util.HashSet<Type> collectTypes(java.lang.String op,
                                            java.util.EnumSet<Descriptor.Kind> mbrOf)

collectTypes

public java.util.HashSet<Type> collectTypes(java.util.EnumSet<Descriptor.Kind> mbrOf)

collectTypes

public java.util.HashSet<Type> collectTypes(java.lang.String op,
                                            DescriptorPredicate p)

collectTypes

public java.util.HashSet<Type> collectTypes(DescriptorPredicate p)

tryLoadVocabulary

public Vocabulary tryLoadVocabulary(java.lang.String vName,
                                    int arity)

instantiate

public Vocabulary instantiate(Vocabulary voc,
                              java.util.ArrayList<Type> actuals)

vocabForType

public Vocabulary vocabForType(java.lang.String tName,
                               int arity)

vocabForName

public Vocabulary vocabForName(java.lang.String vName)
The method returns the vocabulary representation for a given name.

Parameters:
vName - The name of the vocabulary to find.
Returns:
The vocabulary desciptor. The method can return either a loaded vocabulary or a pre-defined (and not yet loaded) vocabulary. If nothing is known= about vName, the method will create a "fresh" vocabulary and return that.

hasVocabulary

public boolean hasVocabulary(java.lang.String vName)
Returns true if and only if a vocabulary of that name is loaded.

Parameters:
vName - the name of the vocabulary to search
Returns:
true if such a vocabulary is loaded

createVocabulary

public Vocabulary createVocabulary(java.lang.String vName)
This method creates a brand new, empty vocabulary.

Parameters:
vName - The name of the vocabulary.
Returns:
The created vocabulary (empty shell).

importVocabulary

public void importVocabulary(Vocabulary voc,
                             boolean fromImport)
This method registers the specified vocabulary as a delegate scope underneath either the current or the global scope

Parameters:
voc - The vocabulary to import
global - Where to insert its scope (as a delegate of the current or the global)