| 1023 | |
| 1024 | |
| 1025 | ASTfunction_call::ASTfunction_call (OSLCompilerImpl *comp, ustring name, |
| 1026 | ASTNode *args, FunctionSymbol *funcsym) |
| 1027 | : ASTNode (function_call_node, comp, 0, args), m_name(name), |
| 1028 | m_sym(funcsym ? funcsym : comp->symtab().find (name)), // Look it up. |
| 1029 | m_poly(funcsym), // Default - resolved symbol or null |
| 1030 | m_argread(~1), // Default - all args are read except the first |
| 1031 | m_argwrite(1), // Default - first arg only is written by the op |
| 1032 | m_argtakesderivs(0) // Default - doesn't take derivs |
| 1033 | { |
| 1034 | if (! m_sym) { |
| 1035 | error ("function '%s' was not declared in this scope", name); |
| 1036 | // FIXME -- would be fun to troll through the symtab and try to |
| 1037 | // find the things that almost matched and offer suggestions. |
| 1038 | return; |
| 1039 | } |
| 1040 | if (is_struct_ctr()) { |
| 1041 | return; // It's a struct constructor |
| 1042 | } |
| 1043 | if (m_sym->symtype() != SymTypeFunction) { |
| 1044 | error ("'%s' is not a function", name.c_str()); |
| 1045 | m_sym = NULL; |
| 1046 | return; |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | |
| 1051 | |