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

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.