- nextthink = parser_expression_leave(parser, true);
- if (!nextthink) {
- ast_unref(framenum);
- parseerror(parser, "expected a think-function in [frame,think] notation");
- return false;
+ if (parser->tok == TOKEN_IDENT && !parser_find_var(parser, parser_tokval(parser)))
+ {
+ /* qc allows the use of not-yet-declared functions here
+ * - this automatically creates a prototype */
+ varentry_t varent;
+ ast_value *thinkfunc;
+ ast_expression *functype = fld_think->expression.next;
+
+ thinkfunc = ast_value_new(parser_ctx(parser), parser_tokval(parser), functype->expression.vtype);
+ if (!thinkfunc || !ast_type_adopt(thinkfunc, functype)) {
+ ast_unref(framenum);
+ parseerror(parser, "failed to create implicit prototype for `%s`", parser_tokval(parser));
+ ast_value_delete(typevar);
+ return false;
+ }
+
+ if (!parser_next(parser)) {
+ ast_unref(framenum);
+ ast_value_delete(typevar);
+ return false;
+ }
+
+ varent.var = (ast_expression*)thinkfunc;
+ varent.name = util_strdup(thinkfunc->name);
+ (void)!parser_t_globals_add(parser, varent);
+ nextthink = (ast_expression*)thinkfunc;
+
+ } else {
+ nextthink = parser_expression_leave(parser, true);
+ if (!nextthink) {
+ ast_unref(framenum);
+ parseerror(parser, "expected a think-function in [frame,think] notation");
+ ast_value_delete(typevar);
+ return false;
+ }