| 57 | """ |
| 58 | |
| 59 | def __init__(self, function, args): |
| 60 | from .function import Function |
| 61 | super(FunctionCall, self).__init__() |
| 62 | |
| 63 | if not isinstance(function, Function): |
| 64 | raise TypeError('FunctionCall needs a Function') |
| 65 | |
| 66 | sig_len = len(function.args) |
| 67 | if len(args) != sig_len: |
| 68 | raise TypeError('Function %s requires %d arguments (got %d)' % |
| 69 | (function.name, sig_len, len(args))) |
| 70 | |
| 71 | # Ensure all expressions |
| 72 | sig = function.args |
| 73 | |
| 74 | self._function = function |
| 75 | |
| 76 | # Convert all arguments to ShaderObject, using arg name if possible. |
| 77 | self._args = [ShaderObject.create(arg, ref=sig[i][1]) |
| 78 | for i, arg in enumerate(args)] |
| 79 | |
| 80 | self._add_dep(function) |
| 81 | for arg in self._args: |
| 82 | self._add_dep(arg) |
| 83 | |
| 84 | def __repr__(self): |
| 85 | return '<FunctionCall of %r at 0x%x>' % (self.function.name, id(self)) |