Vuo
2.4.4
Loading...
Searching...
No Matches
compiler
VuoCompilerPort.cc
Go to the documentation of this file.
1
10
#include "
VuoCable.hh
"
11
#include "
VuoCompilerPort.hh
"
12
#include "
VuoCompilerCable.hh
"
13
#include "
VuoCompilerCodeGenUtilities.hh
"
14
#include "
VuoCompilerPortClass.hh
"
15
#include "
VuoCompilerType.hh
"
16
#include "
VuoException.hh
"
17
#include "
VuoPort.hh
"
18
#include "
VuoStringUtilities.hh
"
19
#include "
VuoType.hh
"
20
24
VuoCompilerPort::VuoCompilerPort
(
VuoPort
*basePort)
25
:
VuoCompilerNodeArgument
(basePort)
26
{
27
dataType = NULL;
28
indexInPortContexts = -1;
29
constantsCache
= NULL;
30
}
31
35
bool
VuoCompilerPort::hasConnectedCable
(
void
)
const
36
{
37
return
(!
getBase
()->getConnectedCables().empty());
38
}
39
43
bool
VuoCompilerPort::hasConnectedDataCable
()
const
44
{
45
vector<VuoCable *> connectedCables =
getBase
()->
getConnectedCables
();
46
for
(vector<VuoCable *>::iterator cable = connectedCables.begin(); cable != connectedCables.end(); ++cable)
47
if
((*cable)->hasCompiler() && (*cable)->getCompiler()->carriesData())
48
return
true
;
49
return
false
;
50
}
51
57
VuoType
*
VuoCompilerPort::getDataVuoType
(
void
)
58
{
59
if
(dataType)
60
return
dataType;
61
62
VuoType
*dataTypeFromClass =
static_cast<
VuoCompilerPortClass
*
>
(
getBase
()->
getClass
()->
getCompiler
())->
getDataVuoType
();
63
if
(dataTypeFromClass)
64
return
dataTypeFromClass;
65
66
return
NULL;
67
}
68
72
void
VuoCompilerPort::setDataVuoType
(
VuoType
*dataType)
73
{
74
this->dataType = dataType;
75
}
76
80
void
VuoCompilerPort::setNodeIdentifier
(
string
nodeIdentifier)
81
{
82
this->nodeIdentifier = nodeIdentifier;
83
}
84
90
string
VuoCompilerPort::getIdentifier
(
void
)
91
{
92
if
(nodeIdentifier.empty())
93
throw
VuoException
(
"VuoCompilerPort::setNodeIdentifier() must be called before VuoCompilerPort::getIdentifier()."
);
94
95
return
VuoStringUtilities::buildPortIdentifier
(nodeIdentifier,
getBase
()->getClass()->getName());
96
}
97
101
void
VuoCompilerPort::setIndexInPortContexts
(
int
indexInPortContexts)
102
{
103
this->indexInPortContexts = indexInPortContexts;
104
}
105
109
int
VuoCompilerPort::getIndexInPortContexts
(
void
)
110
{
111
return
indexInPortContexts;
112
}
113
117
void
VuoCompilerPort::setConstantsCache
(
VuoCompilerConstantsCache
*constantsCache)
118
{
119
this->constantsCache =
constantsCache
;
120
}
121
125
Value *
VuoCompilerPort::getDataVariable
(Module *module, BasicBlock *block, Value *nodeContextValue)
126
{
127
Value *portContextValue =
generateGetPortContext
(module, block, nodeContextValue);
128
return
VuoCompilerCodeGenUtilities::generateGetPortContextDataVariable
(module, block, portContextValue,
getDataVuoType
()->getCompiler());
129
}
130
134
Value *
VuoCompilerPort::generateGetPortContext
(Module *module, BasicBlock *block, Value *nodeContextValue)
135
{
136
if
(indexInPortContexts < 0)
137
throw
VuoException
(
"VuoCompilerPort::setIndexInPortContexts() must be called before VuoCompilerPort::generateGetPortContext()."
);
138
139
return
VuoCompilerCodeGenUtilities::generateGetNodeContextPortContext
(module, block, nodeContextValue, indexInPortContexts);
140
}
Generated on Thu Nov 9 2023 16:59:29 for Vuo by
1.9.8