2017-08-07 18:57:43 -07:00
|
|
|
package org.nwapw.abacus.tree
|
|
|
|
|
2017-08-07 19:11:13 -07:00
|
|
|
/**
|
|
|
|
* A tree node that holds a function call.
|
|
|
|
*
|
|
|
|
* The function call node can hold any number of children, and passes the to the appropriate reducer,
|
|
|
|
* but that is its sole purpose.
|
|
|
|
*
|
|
|
|
* @param function the function string.
|
|
|
|
*/
|
2017-08-25 01:17:52 -07:00
|
|
|
class FunctionNode(function: String) : CallNode(function) {
|
2017-08-07 18:57:43 -07:00
|
|
|
|
|
|
|
override fun <T : Any> reduce(reducer: Reducer<T>): T? {
|
2017-08-08 10:11:30 -07:00
|
|
|
val children = Array<Any>(children.size, { children[it].reduce(reducer) ?: return null; })
|
2017-08-07 18:57:43 -07:00
|
|
|
return reducer.reduceNode(this, *children)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|