pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: program.c,v 1.
685
2008/05/03
15
:
54
:
13
grubba Exp $
+
|| $Id: program.c,v 1.
686
2008/05/03
20
:
06
:
06
grubba Exp $
*/ #include "global.h" #include "program.h" #include "object.h" #include "dynamic_buffer.h" #include "pike_types.h" #include "stralloc.h" #include "las.h" #include "lex.h"
pike.git/src/program.c:8386:
if (((handler = c->handler) && handler->prog && ((fun = find_identifier("handle_inherit", handler->prog)) != -1)) || ((handler = c->compat_handler) && handler->prog && ((fun = find_identifier("handle_inherit", handler->prog)) != -1))) { apply_low(handler, fun, args); } else { apply_external(1, CE_HANDLE_INHERIT_FUN_NUM, args); } }
+
/*! @decl int(0..1) pop_type_attribute(string attribute, @
+
*! type a, type b)
+
*!
+
*! Type attribute handler.
+
*!
+
*! Called during type checking when @expr{a <= b@} and
+
*! @[a] had the type attribute @[attribute] before the
+
*! comparison.
+
*!
+
*! The default implementation implements the "deprecated"
+
*! attribute.
+
*!
+
*! @returns
+
*! Returns @expr{1@} if the type check should be allowed
+
*! (ie @expr{__attribute__(attribute, a) <= b@}), and
+
*! @expr{0@} (zero) otherwise.
+
*!
+
*! @seealso
+
*! @[push_type_attribute()]
+
*/
+
static void f_compilation_pop_type_attribute(INT32 args)
+
{
+
struct pike_string *attr;
+
struct svalue *a, *b;
+
struct compilation *c = THIS_COMPILATION;
+
struct pike_string *deprecated_string;
+
+
get_all_args("pop_type_attribute", args, "%W%*%*", &attr, &a, &b);
+
+
if (Pike_compiler->compiler_pass == 2) {
+
MAKE_CONST_STRING(deprecated_string, "deprecated");
+
if (attr == deprecated_string) {
+
push_int(REPORT_WARNING);
+
ref_push_string(c->lex.current_file);
+
push_int(c->lex.current_line);
+
push_constant_text("type_check");
+
push_constant_text("Using deprecated %O value.");
+
push_svalue(a);
+
apply_current(PC_REPORT_FUN_NUM, 6);
+
args++;
+
}
+
}
+
pop_n_elems(args);
+
push_int(1);
+
}
+
+
/*! @decl int(0..1) push_type_attribute(string attribute, @
+
*! type a, type b)
+
*!
+
*! Type attribute handler.
+
*!
+
*! Called during type checking when @expr{a <= b@} and
+
*! @[b] had the type attribute @[attribute] before the
+
*! comparison.
+
*!
+
*! The default implementation implements the "deprecated"
+
*! attribute.
+
*!
+
*! @returns
+
*! Returns @expr{1@} if the type check should be allowed
+
*! (ie @expr{a <= __attribute__(attribute, b)@}), and
+
*! @expr{0@} (zero) otherwise.
+
*!
+
*! @seealso
+
*! @[pop_type_attribute()]
+
*/
+
static void f_compilation_push_type_attribute(INT32 args)
+
{
+
struct pike_string *attr;
+
struct svalue *a, *b;
+
struct compilation *c = THIS_COMPILATION;
+
struct pike_string *deprecated_string;
+
+
get_all_args("push_type_attribute", args, "%W%*%*", &attr, &a, &b);
+
+
if (Pike_compiler->compiler_pass == 2) {
+
MAKE_CONST_STRING(deprecated_string, "deprecated");
+
if (attr == deprecated_string &&
+
!((a->type == PIKE_T_TYPE) && (a->u.type == zero_type_string))) {
+
/* Don't warn about setting deprecated values to zero. */
+
push_int(REPORT_WARNING);
+
ref_push_string(c->lex.current_file);
+
push_int(c->lex.current_line);
+
push_constant_text("type_check");
+
push_constant_text("Using deprecated %O value.");
+
push_svalue(b);
+
apply_current(PC_REPORT_FUN_NUM, 6);
+
args++;
+
}
+
}
+
pop_n_elems(args);
+
push_int(1);
+
}
+
static void f_compilation__sprintf(INT32 args) { struct compilation *c = THIS_COMPILATION; struct string_builder buf; init_string_builder_alloc(&buf, 50, 0); string_builder_strcat(&buf, "PikeCompiler("); if (c->prog) { string_builder_strcat(&buf, "\"\", "); } else { string_builder_strcat(&buf, "UNDEFINED, ");
pike.git/src/program.c:8657:
ADD_FUNCTION("get_default_module", f_compilation_get_default_module, tFunc(tNone, tOr(tMap(tStr, tMix), tObj)), 0); ADD_FUNCTION("change_compiler_compatibility", f_compilation_change_compiler_compatibility, tFunc(tInt tInt, tVoid), 0); ADD_FUNCTION("handle_inherit", f_compilation_handle_inherit, tFunc(tStr, tPrg(tObj)), 0);
+
ADD_FUNCTION("pop_type_attribute", f_compilation_pop_type_attribute,
+
tFunc(tStr tType(tMix) tType(tMix), tInt01), 0);
+
+
ADD_FUNCTION("push_type_attribute", f_compilation_push_type_attribute,
+
tFunc(tStr tType(tMix) tType(tMix), tInt01), 0);
+
ADD_FUNCTION("_sprintf", f_compilation__sprintf, tFunc(tInt tOr(tMap(tStr, tMix), tVoid), tStr), ID_STATIC); start_new_program(); ADD_STORAGE(struct program_state); Pike_compiler->new_program->event_handler = program_state_event_handler; Pike_compiler->new_program->flags |= PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT|PROGRAM_HAS_C_METHODS;