Vuo  2.0.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
VuoCompilerSpecializedNodeClass Class Reference

Description

A specialization of a generic node class.

When the compiler loads the node classes from the module folders, each generic node class (e.g. vuo.data.hold) is represented by a VuoCompilerNodeClass (not VuoCompilerSpecializedNodeClass) instance.

When the compiler instantiates a specialization of a generic node class to add to a composition, it does this in one of two ways. If the node class is fully specialized (e.g. vuo.data.hold.VuoText), then it looks up or creates the VuoCompilerSpecializedNodeClass with that implementation (e.g. vuo.data.hold.c compiled with VuoText in place of VuoGenericType1). If the node class is not fully specialized (e.g. vuo.data.hold.VuoGenericType1), then it creates a unique VuoCompilerSpecializedNodeClass for that node, and that VuoCompilerSpecializedNodeClass does not yet have an implementation.

When the compiler compiles a composition, each not-fully-specialized VuoCompilerSpecializedNodeClass (e.g. vuo.data.hold.VuoGenericType1) is assigned an implementation, in the form of a "backing" node class (e.g. vuo.data.hold.VuoText). The backing node class is a fully-specialized VuoCompilerSpecializedNodeClass that's effectively substituted in for the not-fully-specialized node class during the compiling of the composition.

If two nodes in a composition are of the same not-fully-specialized node class, then each node has its own unique VuoCompilerSpecializedNodeClass instance. These two VuoCompilerSpecializedNodeClass instances may have different backing node classes or the same backing node class, depending on what each node is connected to in the composition.

Definition at line 42 of file VuoCompilerSpecializedNodeClass.hh.

Public Member Functions

void updateBackingNodeClass (VuoNode *nodeToBack, VuoCompiler *compiler)
 Updates the implementation for this VuoCompilerSpecializedNodeClass to be consistent with the backing types of nodeToBack, and updates the VuoCompilerNode of nodeToBack to be consistent with that implementation. More...
 
virtual VuoCompilerNodecreateReplacementBackingNode (VuoNode *nodeToBack, string backingNodeClassName, VuoCompiler *compiler)
 Returns a fully specialized node of class backingNodeClassName that will replace the node class of nodeToBack. More...
 
bool isFullySpecialized (void)
 Returns true if this node class has no unspecialized generic types. More...
 
virtual VuoTypegetOriginalPortType (VuoPortClass *portClass)
 Returns this port's type in the generic node that this specialized node class was derived from. More...
 
virtual string getOriginalGenericNodeClassName (void)
 Returns the original node's class name (without any type suffixes). More...
 
virtual string getOriginalGenericNodeClassDescription (void)
 Returns the original node's description. More...
 
virtual VuoNodeSetgetOriginalGenericNodeSet (void)
 Returns the original node's node set. More...
 
virtual string createUnspecializedNodeClassName (set< VuoPortClass * > portClassesToUnspecialize)
 Returns the name for the node class that would result if the given port were changed back to its original type. More...
 
virtual string createSpecializedNodeClassNameWithReplacement (string genericTypeName, string specializedTypeName)
 Returns the name for the node class that would result if the given (innermost) specialized type were substituted for the given (innermost) generic type in this node class. More...
 
set< string > getDependencies (void)
 Returns the dependencies of the backing node class, if it exists, otherwise this node class. More...
 
- Public Member Functions inherited from VuoCompilerNodeClass
VuoNodenewNode (string title="", double x=0, double y=0)
 Creates a substantial base node instance from this node class. More...
 
VuoNodenewNode (VuoNode *nodeToCopyMetadataFrom)
 Creates a substantial base node instance with its metadata copied from the existing nodeToCopyMetadataFrom. More...
 
virtual ~VuoCompilerNodeClass (void)
 Destructor. More...
 
bool isLikelyImageFilter (void)
 Returns true if this node class is likely an image filter, based on its image-type input and output port counts. More...
 
bool isLikelyImageGenerator (void)
 Returns true if this node class is likely an image generator, based on its image-type input and output port counts. More...
 
bool isLikelyImageTransition (void)
 Returns true if this node class is likely an image transition, based on its image-type input and output port counts. More...
 
int getImagePortCount (bool isInput)
 Returns the number of image-type input or output ports belonging to this node class. More...
 
bool isSubcomposition (void)
 Returns true if this node class is a subcomposition (implemented in Vuo language, as opposed to text code). More...
 
bool isIsf (void)
 Returns true if this node class is implemented in ISF text code. More...
 
void setSourcePath (const string &sourcePath)
 Stores the path of the source file for this node class. More...
 
string getSourcePath (void)
 Returns the stored path of the source file for this node class. More...
 
void setSourceCode (const string &sourceCode)
 Stores the source code for this node class. More...
 
string getSourceCode (void)
 Returns the stored source code for this node class. More...
 
set< pair< string, string > > getContainedNodes (void)
 Returns the nodes (node identifier and node class name) contained within this subcomposition. More...
 
- Public Member Functions inherited from VuoBaseDetail< VuoNodeClass >
 VuoBaseDetail (string description, VuoNodeClass *base)
 Creates a detail class. More...
 
VuoNodeClassgetBase (void) const
 Returns the detail class instance's base class instance. More...
 
void setBase (VuoNodeClass *base)
 Sets the detail class instance's base class instance. More...
 
- Public Member Functions inherited from VuoCompilerModule
virtual ~VuoCompilerModule (void)
 Destructor. More...
 
VuoCompilerTargetSet parseTargetSet (json_object *o, string key)
 Parses the target set value for key in the top level of the JSON object. More...
 
VuoCompilerTargetSet::MacVersion parseMacVersion (string version)
 Parses a Mac OS version from a string. More...
 
VuoCompilerTargetSet getCompatibleTargets (void)
 Returns the set of targets (operating system versions) with which this module is compatible. More...
 
Module * getModule (void)
 Returns this VuoCompilerModule's LLVM module, which other LLVM modules can link to. More...
 
VuoModulegetPseudoBase (void)
 Returns the (pseudo) base for this (pseudo) compiler detail class. More...
 
bool isBuiltIn (void)
 Returns true if this module is one of the built-in modules distributed with Vuo. More...
 
void setBuiltIn (bool builtIn)
 Sets whether this module is one of the built-in modules distributed with Vuo. More...
 
string getModulePath (void)
 Returns the file from which the LLVM module was loaded, or an empty string if the module was contained in an archive or generated by the compiler. More...
 

Static Public Member Functions

static bool hasGenericPortTypes (VuoCompilerNodeClass *nodeClass)
 Returns true if the node class has at least one unspecialized generic type. More...
 
static VuoNodeClassnewNodeClass (const string &nodeClassName, VuoCompiler *compiler, dispatch_queue_t llvmQueue)
 Generates a specalized node class from a generic node class. More...
 
static VuoCompilerNodeClassgetNodeClassForNode (VuoCompilerNodeClass *origNodeClass, VuoCompiler *compiler)
 Returns the node class to use for instantiating a node within a composition. More...
 
static bool isSpecializationOfNodeClass (const string &potentialSpecializedNodeClassName, VuoCompilerNodeClass *potentialGenericNodeClass)
 Returns true if potentialSpecializedNodeClassName is one of the possible specializations of potentialGenericNodeClass. More...
 
static void replaceGenericTypesWithBacking (string &nodeClassSource)
 Replaces all occurrences of generic type names in the node class source code with a default actual type name. More...
 
- Static Public Member Functions inherited from VuoCompilerNodeClass
static VuoNodeClassnewNodeClass (string nodeClassName, Module *module)
 Creates a new substantial VuoNodeClass from the node class definition in the module. More...
 
static VuoNodeClassnewNodeClassWithoutImplementation (VuoNodeClass *baseNodeClass)
 Creates a new implementation-less compiler node class, using the given node class for its base VuoNodeClass. More...
 
- Static Public Member Functions inherited from VuoCompilerModule
static VuoCompilerModulenewModule (const string &moduleKey, Module *module, const string &modulePath)
 Instantiates a VuoCompilerModule (or child class) corresponding to the type of VuoCompilerModule defined in the LLVM module. More...
 
static Function * declareFunctionInModule (Module *module, Function *function)
 Copies the function's header into the LLVM module, if it's not already there. More...
 

Protected Member Functions

 VuoCompilerSpecializedNodeClass (string nodeClassName, Module *module)
 Creates a specialized node class implementation from an LLVM module, and creates its corresponding base VuoNodeClass. More...
 
 VuoCompilerSpecializedNodeClass (VuoCompilerSpecializedNodeClass *compilerNodeClass)
 Creates a new compiler node class and creates a new base VuoNodeClass, both from compilerNodeClass. More...
 
 VuoCompilerSpecializedNodeClass (VuoNodeClass *baseNodeClass)
 Creates a new implementation-less compiler node class, using the given node class for its base VuoNodeClass. More...
 
- Protected Member Functions inherited from VuoCompilerNodeClass
 VuoCompilerNodeClass (string className, Module *module)
 Creates a node class implementation from an LLVM module, and creates its corresponding base VuoNodeClass. More...
 
 VuoCompilerNodeClass (VuoCompilerNodeClass *compilerNodeClass)
 Creates a new compiler node class and creates a new base VuoNodeClass, both from compilerNodeClass. More...
 
 VuoCompilerNodeClass (VuoNodeClass *baseNodeClass)
 Creates a new implementation-less compiler node class, using the given node class for its base VuoNodeClass. More...
 
VuoPortClassgetInputPortClassWithName (string portName)
 Returns the input port class matching the specified portName, if one exists. More...
 
VuoPortClassgetOutputPortClassWithName (string portName)
 Returns the output port class matching the specified portName, if one exists. More...
 
- Protected Member Functions inherited from VuoCompilerModule
 VuoCompilerModule (VuoModule *base, Module *module)
 Creates a VuoCompilerModule associated with the given LLVM module, as a pseudo compiler detail class of the given VuoModule. More...
 
string nameForGlobal (string genericGlobalVarOrFuncName)
 Returns the mangled name for a function or global variable. More...
 
void renameGlobalVarsAndFuncs (void)
 Renames the global variables and functions within the LLVM module so that they are unique to this VuoCompilerModule. More...
 

Static Protected Member Functions

static VuoPortClasscopyPortClassFromModel (VuoPortClass *modelPortClass, bool isInput)
 Creates a new port class (base + compiler detail) with properties copied from modelPortClass (base + compiler detail). More...
 
- Static Protected Member Functions inherited from VuoCompilerNodeClass
static void parseGenericTypes (json_object *moduleDetails, map< string, string > &defaultSpecializedForGenericTypeName, map< std::string, vector< std::string > > &compatibleSpecializedForGenericTypeName)
 Parses the "genericTypes" portion of a node class's metadata. More...
 
- Static Protected Member Functions inherited from VuoCompilerModule
static string nameForGlobal (string nameBeforeCompilation, string moduleKey)
 Returns the mangled name for a function or global variable. More...
 
static bool hasOriginalOrMangledGlobal (string nameBeforeCompilation, Module *module, string moduleKey)
 Returns true if the module contains a function or global variable with name nameBeforeCompilation or with the corresponding mangled name. More...
 

Protected Attributes

map< string, string > specializedForGenericTypeName
 The type name that replaces each generic type name in the original generic node class. More...
 
- Protected Attributes inherited from VuoCompilerNodeClass
map< string, string > defaultSpecializedForGenericTypeName
 If this node class is generic, use these specialized types when creating an instance. More...
 
- Protected Attributes inherited from VuoCompilerModule
struct json_objectmoduleDetails
 This module's metadata, found in the argument to VuoModuleMetadata in the module definition. More...
 
set< string > dependencies
 The dependencies found in this module's metadata. More...
 
Module * module
 The LLVM module that defines this node class or type. More...
 
VuoCompilerBitcodeParserparser
 The parser of the LLVM module. More...
 

Friends

class TestNodes
 
class TestVuoCompilerNodeClass
 
string getDependencyName (void)
 If the backing node class exists, this function is performed on the backing node class instead of this node class. More...
 

Constructor & Destructor Documentation

◆ VuoCompilerSpecializedNodeClass() [1/3]

VuoCompilerSpecializedNodeClass::VuoCompilerSpecializedNodeClass ( string  nodeClassName,
Module *  module 
)
protected

Creates a specialized node class implementation from an LLVM module, and creates its corresponding base VuoNodeClass.

Definition at line 35 of file VuoCompilerSpecializedNodeClass.cc.

◆ VuoCompilerSpecializedNodeClass() [2/3]

VuoCompilerSpecializedNodeClass::VuoCompilerSpecializedNodeClass ( VuoCompilerSpecializedNodeClass compilerNodeClass)
protected

Creates a new compiler node class and creates a new base VuoNodeClass, both from compilerNodeClass.

Definition at line 44 of file VuoCompilerSpecializedNodeClass.cc.

◆ VuoCompilerSpecializedNodeClass() [3/3]

VuoCompilerSpecializedNodeClass::VuoCompilerSpecializedNodeClass ( VuoNodeClass baseNodeClass)
protected

Creates a new implementation-less compiler node class, using the given node class for its base VuoNodeClass.

Definition at line 53 of file VuoCompilerSpecializedNodeClass.cc.

Member Function Documentation

◆ copyPortClassFromModel()

VuoPortClass * VuoCompilerSpecializedNodeClass::copyPortClassFromModel ( VuoPortClass modelPortClass,
bool  isInput 
)
staticprotected

Creates a new port class (base + compiler detail) with properties copied from modelPortClass (base + compiler detail).

Definition at line 320 of file VuoCompilerSpecializedNodeClass.cc.

◆ createReplacementBackingNode()

VuoCompilerNode * VuoCompilerSpecializedNodeClass::createReplacementBackingNode ( VuoNode nodeToBack,
string  backingNodeClassName,
VuoCompiler compiler 
)
virtual

Returns a fully specialized node of class backingNodeClassName that will replace the node class of nodeToBack.

Reimplemented in VuoCompilerPublishedNodeClass.

Definition at line 489 of file VuoCompilerSpecializedNodeClass.cc.

◆ createSpecializedNodeClassNameWithReplacement()

string VuoCompilerSpecializedNodeClass::createSpecializedNodeClassNameWithReplacement ( string  genericTypeName,
string  specializedTypeName 
)
virtual

Returns the name for the node class that would result if the given (innermost) specialized type were substituted for the given (innermost) generic type in this node class.

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 790 of file VuoCompilerSpecializedNodeClass.cc.

◆ createUnspecializedNodeClassName()

string VuoCompilerSpecializedNodeClass::createUnspecializedNodeClassName ( set< VuoPortClass * >  portClassesToUnspecialize)
virtual

Returns the name for the node class that would result if the given port were changed back to its original type.

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 759 of file VuoCompilerSpecializedNodeClass.cc.

◆ getDependencies()

set< string > VuoCompilerSpecializedNodeClass::getDependencies ( void  )
virtual

Returns the dependencies of the backing node class, if it exists, otherwise this node class.

The list of dependencies includes the generic node class that this node class specializes.

Reimplemented from VuoCompilerModule.

Definition at line 929 of file VuoCompilerSpecializedNodeClass.cc.

◆ getDependencyName()

string VuoCompilerSpecializedNodeClass::getDependencyName ( void  )
virtual

If the backing node class exists, this function is performed on the backing node class instead of this node class.

Reimplemented from VuoCompilerModule.

Definition at line 918 of file VuoCompilerSpecializedNodeClass.cc.

◆ getNodeClassForNode()

VuoCompilerNodeClass * VuoCompilerSpecializedNodeClass::getNodeClassForNode ( VuoCompilerNodeClass origNodeClass,
VuoCompiler compiler 
)
static

Returns the node class to use for instantiating a node within a composition.

  • If origNodeClass doesn't have any generic types, then origNodeClass itself is returned.
  • If origNodeClass is a partially-specialized generic node class (e.g. vuo.osc.message.get.2.VuoReal.VuoGenericType2), then a new VuoCompilerSpecializedNodeClass is returned, to be unique to the created node.
  • If origNodeClass is a generic node class that the compiler loaded from the modules folders (e.g. vuo.osc.message.get.2), then a new or existing VuoCompilerSpecializedNodeClass is returned, depending on which of the two above cases applies to the node class after it has been specialized with its default types, if any.

Definition at line 394 of file VuoCompilerSpecializedNodeClass.cc.

◆ getOriginalGenericNodeClassDescription()

string VuoCompilerSpecializedNodeClass::getOriginalGenericNodeClassDescription ( void  )
virtual

Returns the original node's description.

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 743 of file VuoCompilerSpecializedNodeClass.cc.

◆ getOriginalGenericNodeClassName()

string VuoCompilerSpecializedNodeClass::getOriginalGenericNodeClassName ( void  )
virtual

Returns the original node's class name (without any type suffixes).

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 735 of file VuoCompilerSpecializedNodeClass.cc.

◆ getOriginalGenericNodeSet()

VuoNodeSet * VuoCompilerSpecializedNodeClass::getOriginalGenericNodeSet ( void  )
virtual

Returns the original node's node set.

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 751 of file VuoCompilerSpecializedNodeClass.cc.

◆ getOriginalPortType()

VuoType * VuoCompilerSpecializedNodeClass::getOriginalPortType ( VuoPortClass portClass)
virtual

Returns this port's type in the generic node that this specialized node class was derived from.

Reimplemented in VuoCompilerPublishedNodeClass, and VuoCompilerMakeListNodeClass.

Definition at line 702 of file VuoCompilerSpecializedNodeClass.cc.

◆ hasGenericPortTypes()

bool VuoCompilerSpecializedNodeClass::hasGenericPortTypes ( VuoCompilerNodeClass nodeClass)
static

Returns true if the node class has at least one unspecialized generic type.

Definition at line 629 of file VuoCompilerSpecializedNodeClass.cc.

◆ isFullySpecialized()

bool VuoCompilerSpecializedNodeClass::isFullySpecialized ( void  )

Returns true if this node class has no unspecialized generic types.

Definition at line 621 of file VuoCompilerSpecializedNodeClass.cc.

◆ isSpecializationOfNodeClass()

bool VuoCompilerSpecializedNodeClass::isSpecializationOfNodeClass ( const string &  potentialSpecializedNodeClassName,
VuoCompilerNodeClass potentialGenericNodeClass 
)
static

Returns true if potentialSpecializedNodeClassName is one of the possible specializations of potentialGenericNodeClass.

Definition at line 421 of file VuoCompilerSpecializedNodeClass.cc.

◆ newNodeClass()

VuoNodeClass * VuoCompilerSpecializedNodeClass::newNodeClass ( const string &  nodeClassName,
VuoCompiler compiler,
dispatch_queue_t  llvmQueue 
)
static

Generates a specalized node class from a generic node class.

Parameters
nodeClassNameThe name of the node class to generate. It should have the format "<generic node class name>.<type>.(...).<type>" (e.g. "vuo.dictionary.make.VuoText.VuoInteger").
compilerThe compiler to use for looking up the generic node class and compiling the specialized node class.
llvmQueueSynchronizes access to LLVM's global context.
Returns
The generated node class, or null if the generic node class is not found. If nodeClassName is fully specialized (doesn't contain any generic type names), then the returned node class has an LLVM module associated with it. Otherwise, the returned node class does not yet have an implementation.

Definition at line 79 of file VuoCompilerSpecializedNodeClass.cc.

◆ replaceGenericTypesWithBacking()

void VuoCompilerSpecializedNodeClass::replaceGenericTypesWithBacking ( string &  nodeClassSource)
static

Replaces all occurrences of generic type names in the node class source code with a default actual type name.

Definition at line 541 of file VuoCompilerSpecializedNodeClass.cc.

◆ updateBackingNodeClass()

void VuoCompilerSpecializedNodeClass::updateBackingNodeClass ( VuoNode nodeToBack,
VuoCompiler compiler 
)

Updates the implementation for this VuoCompilerSpecializedNodeClass to be consistent with the backing types of nodeToBack, and updates the VuoCompilerNode of nodeToBack to be consistent with that implementation.

Definition at line 436 of file VuoCompilerSpecializedNodeClass.cc.

Member Data Documentation

◆ specializedForGenericTypeName

map<string, string> VuoCompilerSpecializedNodeClass::specializedForGenericTypeName
protected

The type name that replaces each generic type name in the original generic node class.

Definition at line 76 of file VuoCompilerSpecializedNodeClass.hh.


The documentation for this class was generated from the following files: