29#ifndef __SCRIPTCOMPILER_H_
30#define __SCRIPTCOMPILER_H_
192 typedef HashMap<String,uint32>
IdMap;
218 CE_REFERENCETOANONEXISTINGOBJECT
555 :
ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup), mSource(source),
556 mSyntax(syntax), mProgramType(programType)
569 :
ScriptCompilerEvent(eventType), mFile(file), mName(name), mResourceGroup(resourceGroup), mSource(source),
570 mLanguage(language), mProgramType(programType)
879#ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
virtual String getValue() const =0
Returns a string value depending on the type of the AbstractNode.
virtual AbstractNode * clone() const =0
Returns a new AbstractNode which is a replica of this one.
AbstractNode(AbstractNode *ptr)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Variant type that can hold Any other type.
This is an abstract node which cannot be broken down further.
AtomAbstractNode(AbstractNode *ptr)
String getValue() const
Returns a string value depending on the type of the AbstractNode.
AbstractNode * clone() const
Returns a new AbstractNode which is a replica of this one.
CreateCompositorScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup)
CreateGpuProgramScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup, const String &source, const String &syntax, GpuProgramType programType)
GpuProgramType mProgramType
CreateHighLevelGpuProgramScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup, const String &source, const String &language, GpuProgramType programType)
GpuProgramType mProgramType
CreateMaterialScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup)
CreateParticleSystemScriptCompilerEvent(const String &file, const String &name, const String &resourceGroup)
This abstract node represents an import statement.
String getValue() const
Returns a string value depending on the type of the AbstractNode.
AbstractNode * clone() const
Returns a new AbstractNode which is a replica of this one.
Class encapsulates rendering properties of an object.
This specific abstract node represents a script object.
String getValue() const
Returns a string value depending on the type of the AbstractNode.
void addVariable(const String &name)
AbstractNodeList overrides
const map< String, String >::type & getVariables() const
void setVariable(const String &name, const String &value)
map< String, String >::type mEnv
AbstractNodeList children
ObjectAbstractNode(AbstractNode *ptr)
vector< String >::type bases
AbstractNode * clone() const
Returns a new AbstractNode which is a replica of this one.
std::pair< bool, String > getVariable(const String &name) const
AliasTextureNamePairList * mAliases
PreApplyTextureAliasesScriptCompilerEvent(Material *material, AliasTextureNamePairList *aliases)
ProcessNameExclusionScriptCompilerEvent(const String &cls, AbstractNode *parent)
ProcessResourceNameScriptCompilerEvent(ResourceType resourceType, const String &name)
ResourceType mResourceType
This abstract node represents a script property.
String getValue() const
Returns a string value depending on the type of the AbstractNode.
AbstractNode * clone() const
Returns a new AbstractNode which is a replica of this one.
PropertyAbstractNode(AbstractNode *ptr)
This struct is a base class for events which can be thrown by the compilers and caught by subscribers...
virtual ~ScriptCompilerEvent()
ScriptCompilerEvent & operator=(const ScriptCompilerEvent &)
ScriptCompilerEvent(const String &type)
ScriptCompilerEvent(const ScriptCompilerEvent &)
This is a listener for the compiler.
virtual ConcreteNodeListPtr importFile(ScriptCompiler *compiler, const String &name)
Returns the concrete node list from the given file.
virtual bool handleEvent(ScriptCompiler *compiler, ScriptCompilerEvent *evt, void *retval)
Called when an event occurs during translation, return true if handled.
virtual ~ScriptCompilerListener()
virtual void preConversion(ScriptCompiler *compiler, ConcreteNodeListPtr nodes)
Allows for responding to and overriding behavior before a CST is translated into an AST.
virtual bool postConversion(ScriptCompiler *compiler, const AbstractNodeListPtr &)
Allows vetoing of continued compilation after the entire AST conversion process finishes.
virtual void handleError(ScriptCompiler *compiler, uint32 code, const String &file, int line, const String &msg)
Called when an error occurred.
Manages threaded compilation of scripts.
void removeTranslatorManager(ScriptTranslatorManager *man)
Removes the given translator manager from the list of managers.
vector< ScriptTranslatorManager * >::type mManagers
static ScriptCompilerManager & getSingleton(void)
Override standard Singleton retrieval.
ScriptTranslatorManager * mBuiltinTranslatorManager
void setListener(ScriptCompilerListener *listener)
Sets the listener used for compiler instances.
void addScriptPattern(const String &pattern)
Adds a script extension that can be handled (e.g. *.material, *.pu, etc.)
StringVector mScriptPatterns
OGRE_THREAD_POINTER(ScriptCompiler, mScriptCompiler)
void parseScript(DataStreamPtr &stream, const String &groupName)
Parse a script file.
const StringVector & getScriptPatterns(void) const
Gets the file patterns which should be used to find scripts for this class.
void addTranslatorManager(ScriptTranslatorManager *man)
Adds the given translator manager to the list of managers.
void clearTranslatorManagers()
Clears all translator managers.
virtual ~ScriptCompilerManager()
ScriptCompilerListener * getListener()
Returns the currently set listener used for compiler instances.
ScriptTranslator * getTranslator(const AbstractNodePtr &node)
Retrieves a ScriptTranslator from the supported managers.
static ScriptCompilerManager * getSingletonPtr(void)
Override standard Singleton retrieval.
ScriptCompilerListener * mListener
Real getLoadingOrder(void) const
Gets the relative loading order of scripts of this type.
uint32 registerCustomWordId(const String &word)
Adds a custom word id which can be used for custom script translators.
void visit(ConcreteNode *node)
static void visit(AbstractTreeBuilder *visitor, const ConcreteNodeList &nodes)
AbstractNodeListPtr mNodes
AbstractTreeBuilder(ScriptCompiler *compiler)
const AbstractNodeListPtr & getResult() const
ScriptCompiler * mCompiler
This is the main class for the compiler.
map< String, String >::type Environment
bool _compile(AbstractNodeListPtr nodes, const String &group, bool doImports=true, bool doObjects=true, bool doVariables=true)
Compiles the given abstract syntax tree.
const String & getResourceGroup() const
Returns the resource group currently set for this compiler.
uint32 registerCustomWordId(const String &word)
Adds a custom word id which can be used for custom script translators.
AbstractNodeListPtr convertToAST(const ConcreteNodeListPtr &nodes)
void processObjects(AbstractNodeList *nodes, const AbstractNodeListPtr &top)
Handles object inheritance and variable expansion.
bool compile(const ConcreteNodeListPtr &nodes, const String &group)
Compiles resources from the given concrete node list.
uint32 mLargestRegisteredWordId
ScriptCompilerListener * getListener()
Returns the currently set listener.
void processImports(AbstractNodeListPtr &nodes)
This built-in function processes import nodes.
void addError(uint32 code, const String &file, int line, const String &msg="")
Adds the given error to the compiler's list of errors.
HashMap< String, uint32 > IdMap
static String formatErrorCode(uint32 code)
void processVariables(AbstractNodeList *nodes)
Handles processing the variables.
void overlayObject(const AbstractNodePtr &source, ObjectAbstractNode *dest)
This function overlays the given object on the destination object following inheritance rules.
bool isNameExcluded(const String &cls, AbstractNode *parent)
Returns true if the given class is name excluded.
bool _fireEvent(ScriptCompilerEvent *evt, void *retval)
Internal method for firing the handleEvent method.
multimap< String, String >::type ImportRequestMap
AbstractNodeListPtr locateTarget(AbstractNodeList *nodes, const String &target)
Returns the abstract nodes from the given tree which represent the target.
AbstractNodeList mImportTable
SharedPtr< Error > ErrorPtr
ImportRequestMap mImportRequests
bool compile(const String &str, const String &source, const String &group)
Takes in a string of script code and compiles it into resources.
AbstractNodeListPtr _generateAST(const String &str, const String &source, bool doImports=false, bool doObjects=false, bool doVariables=false)
Generates the AST from the given string script.
list< ErrorPtr >::type ErrorList
AbstractNodeListPtr loadImportPath(const String &name)
Loads the requested script and converts it to an AST.
ScriptCompilerListener * mListener
@ CE_FEWERPARAMETERSEXPECTED
@ CE_UNSUPPORTEDBYRENDERSYSTEM
@ CE_OBJECTALLOCATIONERROR
void setListener(ScriptCompilerListener *listener)
Sets the listener used by the compiler.
virtual ~ScriptCompiler()
map< String, AbstractNodeListPtr >::type ImportCacheMap
void removeNameExclusion(const String &type)
Removes a name exclusion.
void addNameExclusion(const String &type)
Adds a name exclusion to the map.
void initWordMap()
This function sets up the initial values in word id map.
Abstract class defining the interface used by classes which wish to perform script loading to define ...
The ScriptTranslatorManager manages the lifetime and access to script translators.
This class translates script AST (abstract syntax tree) into Ogre resources.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Template class for creating single-instance global classes.
This abstract node represents a variable assignment.
VariableAccessAbstractNode(AbstractNode *ptr)
String getValue() const
Returns a string value depending on the type of the AbstractNode.
AbstractNode * clone() const
Returns a new AbstractNode which is a replica of this one.
vector< String >::type StringVector
SharedPtr< AbstractNode > AbstractNodePtr
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
SharedPtr< ConcreteNode > ConcreteNodePtr
AbstractNodeType
This enum holds the types of the possible abstract nodes.
SharedPtr< ConcreteNodeList > ConcreteNodeListPtr
list< ConcreteNodePtr >::type ConcreteNodeList
SharedPtr< AbstractNodeList > AbstractNodeListPtr
ConcreteNodeType
These enums hold the types of the concrete parsed nodes.
list< AbstractNodePtr >::type AbstractNodeList
@ ID_ONE_MINUS_DEST_ALPHA
@ ID_CAMERA_FAR_CORNERS_WORLD_SPACE
@ ID_SHADOW_CASTER_VERTEX_PROGRAM_REF
@ ID_BLEND_DIFFUSE_COLOUR
@ ID_TESSELATION_HULL_PROGRAM_REF
@ ID_SHADOW_RECEIVER_MATERIAL
@ ID_TESSELATION_DOMAIN_PROGRAM_REF
@ ID_POINT_SIZE_ATTENUATION
@ ID_SHADOW_RECEIVER_FRAGMENT_PROGRAM_REF
@ ID_SHADOW_RECEIVER_VERTEX_PROGRAM_REF
@ ID_COLOUR_OP_MULTIPASS_FALLBACK
@ ID_ONE_MINUS_DEST_COLOUR
@ ID_CAMERA_FAR_CORNERS_VIEW_SPACE
@ ID_TARGET_HEIGHT_SCALED
@ ID_SHADOW_CASTER_MATERIAL
@ ID_SEPARATE_SCENE_BLEND_OP
@ ID_ONE_MINUS_SRC_COLOUR
@ ID_GEOMETRY_PROGRAM_REF
@ ID_TRANSPARENCY_CASTS_SHADOWS
@ ID_POLYGON_MODE_OVERRIDEABLE
@ ID_ITERATION_DEPTH_BIAS
@ ID_FRAGMENT_PROGRAM_REF
@ ID_SHADOW_CASTER_FRAGMENT_PROGRAM_REF
@ ID_TESSELATION_HULL_PROGRAM
Suport for shader model 5.0.
@ ID_SEPARATE_SCENE_BLEND
@ ID_TESSELATION_DOMAIN_PROGRAM
GpuProgramType
Enumerates the types of programs which can run on the GPU.
float Real
Software floating point type.
ConcreteNodeList children
std::map< K, V, P, A > type
std::multimap< K, V, P, A > type