Branch: Tag:

2013-04-21

2013-04-21 10:12:07 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Added resolve_program().

Added helper function resolve_program() to simplify resolving of
program symbols during compile-time for C-modules.

This function is used from precompiled code when inheriting
strings (API level 5).

1850:    return ret;   }    + /* This function is intended to simplify resolving of +  * program symbols during compile-time for C-modules. +  * +  * A typical use-case is for a C-module inheriting +  * code written in Pike. +  */ + PMOD_EXPORT struct program *resolve_program(struct pike_string *ident) + { +  struct program *ret = NULL; +  struct node_s *n = resolve_identifier(ident); +  if (n) { +  if ((n->token == F_CONSTANT) && (TYPEOF(n->u.sval) == T_PROGRAM) && +  (ret = n->u.sval.u.program)) { +  add_ref(ret); +  } else { +  my_yyerror("Invalid program identifier '%S'.", ident); +  } +  free_node(n); +  } else { +  my_yyerror("Unknown program identifier '%S'.", ident); +  } +  return ret; + } +    /*! @decl constant this    *!    *! Builtin read only variable that evaluates to the current object.