2020/// writeVariables - {[String,...]} List of variables write operations occur
2121///
2222var functionNode = ( function ( ) {
23-
23+
2424 //
2525 // Constructor
2626 //----------------------------------------------------------------------------------------------------
27-
27+
2828 ///
2929 /// Function: functionNode
3030 ///
@@ -38,24 +38,24 @@ var functionNode = (function() {
3838 /// returnType - {String} The return type, assumes "float" if null
3939 ///
4040 function functionNode ( gpu , functionName , jsFunction , paramTypeArray , returnType ) {
41-
41+
4242 this . gpu = gpu ;
43-
43+
4444 //
4545 // Internal vars setup
4646 //
4747 this . calledFunctions = [ ] ;
4848 this . initVariables = [ ] ;
4949 this . readVariables = [ ] ;
5050 this . writeVariables = [ ] ;
51-
51+
5252 //
5353 // Missing jsFunction object exception
5454 //
5555 if ( jsFunction == null ) {
5656 throw "jsFunction, parameter is null" ;
5757 }
58-
58+
5959 //
6060 // Setup jsFunction and its string property + validate them
6161 //
@@ -64,22 +64,22 @@ var functionNode = (function() {
6464 console . error ( "jsFunction, to string conversion check falied: not a function?" , this . jsFunctionString ) ;
6565 throw "jsFunction, to string conversion check falied: not a function?" ;
6666 }
67-
67+
6868 if ( ! isFunction ( jsFunction ) ) {
6969 //throw "jsFunction, is not a valid JS Function";
7070 this . jsFunction = null ;
7171 } else {
7272 this . jsFunction = jsFunction ;
7373 }
74-
74+
7575 //
7676 // Setup the function name property
7777 //
7878 this . functionName = functionName || ( jsFunction && jsFunction . name ) || FUNCTION_NAME . exec ( this . jsFunctionString ) [ 1 ] ;
7979 if ( ! ( this . functionName ) ) {
8080 throw "jsFunction, missing name argument or value" ;
8181 }
82-
82+
8383 //
8484 // Extract parameter name, and its argument types
8585 //
@@ -98,23 +98,23 @@ var functionNode = (function() {
9898 this . paramType . push ( "float" ) ;
9999 }
100100 }
101-
101+
102102 //
103103 // Return type handling
104104 //
105105 this . returnType = returnType || "float" ;
106106 }
107-
107+
108108 //
109109 // Utility functions
110110 //----------------------------------------------------------------------------------------------------
111-
111+
112112 ///
113113 /// Function: isFunction
114114 ///
115115 /// [static] Return TRUE, on a JS function
116116 ///
117- /// This is 'static' function, not a class function ( functionNode.prototype )
117+ /// This is 'static' function, not a class function functionNode.isFunction(... )
118118 ///
119119 /// Parameters:
120120 /// funcObj - {JS Function} Object to validate if its a function
@@ -125,13 +125,13 @@ var functionNode = (function() {
125125 function isFunction ( funcObj ) {
126126 return typeof ( funcObj ) === 'function' ;
127127 }
128-
128+
129129 ///
130130 /// Function: validateStringIsFunction
131131 ///
132132 /// [static] Return TRUE, on a valid JS function string
133133 ///
134- /// This is 'static' function, not a class function ( functionNode.prototype )
134+ /// This is 'static' function, not a class function functionNode.validateStringIsFunction(... )
135135 ///
136136 /// Parameters:
137137 /// funcStr - {String} String of JS function to validate
@@ -145,17 +145,17 @@ var functionNode = (function() {
145145 }
146146 return false ;
147147 }
148-
148+
149149 var FUNCTION_NAME = / f u n c t i o n ( [ ^ ( ] * ) / ;
150150 var STRIP_COMMENTS = / ( ( \/ \/ .* $ ) | ( \/ \* [ \s \S ] * ?\* \/ ) ) / mg;
151151 var ARGUMENT_NAMES = / ( [ ^ \s , ] + ) / g;
152-
152+
153153 ///
154154 /// Function: getParamNames
155155 ///
156156 /// [static] Return list of parameter names extracted from the JS function string
157157 ///
158- /// This is 'static' function, not a class function ( functionNode.prototype )
158+ /// This is 'static' function, not a class function: functionNode.getParamNames(... )
159159 ///
160160 /// Parameters:
161161 /// funcStr - {String} String of JS function to validate
@@ -176,34 +176,34 @@ var functionNode = (function() {
176176 functionNode . isFunction = isFunction ;
177177 functionNode . validateStringIsFunction = validateStringIsFunction ;
178178 functionNode . getParamNames = getParamNames ;
179-
179+
180180 //
181181 // Core function
182182 //----------------------------------------------------------------------------------------------------
183-
183+
184184 ///
185185 /// Function: getJSFunction
186186 ///
187187 /// Gets and return the stored JS Function.
188188 /// Note: that this internally eval the function, if only the string was provided on construction
189189 ///
190190 /// Returns:
191- /// {JS Function} The function object
191+ /// {JS Function} The function object
192192 ///
193193 function getJSFunction ( ) {
194194 if ( this . jsFunction ) {
195195 return this . jsFunction ;
196196 }
197-
197+
198198 if ( this . jsFunctionString ) {
199199 this . jsFunction = eval ( this . jsFunctionString ) ;
200200 return this . jsFunction ;
201201 }
202-
202+
203203 throw "Missin jsFunction, and jsFunctionString parameter" ;
204204 }
205205 functionNode . prototype . getJSFunction = getJSFunction ;
206-
206+
207207 ///
208208 /// Function: getJS_AST
209209 ///
@@ -221,25 +221,25 @@ var functionNode = (function() {
221221 if ( this . jsFunctionAST ) {
222222 return this . jsFunctionAST ;
223223 }
224-
224+
225225 inParser = inParser || parser ;
226226 if ( inParser == null ) {
227227 throw "Missing JS to AST parser" ;
228228 }
229-
229+
230230 var prasedObj = parser . parse ( "var " + this . functionName + " = " + this . jsFunctionString + ";" ) ;
231231 if ( prasedObj === null ) {
232232 throw "Failed to parse JS code via JISON" ;
233233 }
234-
234+
235235 // take out the function object, outside the var declarations
236236 var funcAST = prasedObj . body [ 0 ] . declarations [ 0 ] . init ;
237237 this . jsFunctionAST = funcAST ;
238-
238+
239239 return funcAST ;
240240 }
241241 functionNode . prototype . getJS_AST = getJS_AST ;
242-
242+
243243 ///
244244 /// Function: getWebglString
245245 ///
@@ -252,11 +252,11 @@ var functionNode = (function() {
252252 if ( this . webglFunctionString ) {
253253 return this . webglFunctionString ;
254254 }
255-
255+
256256 return this . webglFunctionString = functionNode_webgl ( this ) ;
257257 }
258258 functionNode . prototype . getWebglFunctionString = getWebglFunctionString ;
259-
259+
260260 ///
261261 /// Function: setWebglString
262262 ///
@@ -269,6 +269,6 @@ var functionNode = (function() {
269269 this . webglFunctionString = shaderCode ;
270270 }
271271 functionNode . prototype . setWebglFunctionString = setWebglFunctionString ;
272-
272+
273273 return functionNode ;
274274} ) ( ) ;
0 commit comments