e576bb | 2002-10-11 | Martin Nilsson | |
|
aedfb1 | 2002-10-09 | Martin Nilsson | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "global.h"
#include "program.h"
#include "object.h"
|
2d10fb | 2016-12-29 | Arne Goedeke | | #include "buffer.h"
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | #include "pike_types.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "stralloc.h"
#include "las.h"
#include "lex.h"
|
bb55f8 | 1997-03-16 | Fredrik Hübinette (Hubbe) | | #include "pike_macros.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "fsort.h"
|
b2d3e4 | 2000-12-01 | Fredrik Hübinette (Hubbe) | | #include "pike_error.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "docode.h"
#include "interpret.h"
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | #include "main.h"
|
9173f7 | 2002-11-25 | Martin Stjernholm | | #include "pike_memory.h"
|
624d09 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | #include "gc.h"
|
07513e | 1996-10-04 | Fredrik Hübinette (Hubbe) | | #include "threads.h"
|
0683be | 1997-01-26 | Fredrik Hübinette (Hubbe) | | #include "constants.h"
|
9c6f7d | 1997-04-15 | Fredrik Hübinette (Hubbe) | | #include "operators.h"
|
3eb19a | 1998-01-30 | Henrik Grubbström (Grubba) | | #include "builtin_functions.h"
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | #include "mapping.h"
#include "cyclic.h"
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | #include "opcodes.h"
|
ac8715 | 2000-09-25 | Fredrik Hübinette (Hubbe) | | #include "version.h"
|
d47659 | 2013-06-12 | Arne Goedeke | | #include "block_allocator.h"
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | #include "block_alloc.h"
|
0e0cd7 | 2001-07-20 | Henrik Grubbström (Grubba) | | #include "pikecode.h"
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | #include "pike_compiler.h"
|
a17300 | 2008-04-15 | Martin Nilsson | | #include "module_support.h"
|
8079a4 | 2014-01-11 | Tobias S. Josefowitz | | #include "bitvector.h"
|
9d1f54 | 2017-01-25 | Henrik Grubbström (Grubba) | | #include "sprintf.h"
|
8aeeb2 | 1996-11-19 | Fredrik Hübinette (Hubbe) | |
#include <errno.h>
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include <fcntl.h>
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | static void exit_program_struct(struct program *);
|
0328ad | 2017-01-31 | Henrik Grubbström (Grubba) | |
static struct mapping *reverse_symbol_table = NULL;
|
d47659 | 2013-06-12 | Arne Goedeke | | static struct block_allocator program_allocator = BA_INIT_PAGES(sizeof(struct program), 4);
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | |
|
d47659 | 2013-06-12 | Arne Goedeke | | ATTRIBUTE((malloc))
|
3b54e5 | 2014-08-21 | Martin Nilsson | | struct program * alloc_program(void) {
|
bd03ba | 2020-12-29 | Henrik Grubbström (Grubba) | | struct program *p = ba_alloc(&program_allocator);
dmalloc_register(p, sizeof(struct program), DMALLOC_LOCATION());
return p;
|
d47659 | 2013-06-12 | Arne Goedeke | | }
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | |
|
d47659 | 2013-06-12 | Arne Goedeke | | void really_free_program(struct program * p) {
exit_program_struct(p);
|
bd03ba | 2020-12-29 | Henrik Grubbström (Grubba) | | dmalloc_unregister(p, 0);
|
d47659 | 2013-06-12 | Arne Goedeke | | ba_free(&program_allocator, p);
}
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | |
|
d47659 | 2013-06-12 | Arne Goedeke | | void count_memory_in_programs(size_t *num, size_t *_size) {
size_t size;
struct program *p;
ba_count_all(&program_allocator, num, &size);
for(p=first_program;p;p=p->next) {
size+=p->total_size - sizeof (struct program);
}
|
5b472b | 2013-11-03 | Arne Goedeke | | *_size = size;
|
d47659 | 2013-06-12 | Arne Goedeke | | }
|
3b54e5 | 2014-08-21 | Martin Nilsson | | void free_all_program_blocks(void) {
|
d47659 | 2013-06-12 | Arne Goedeke | | ba_destroy(&program_allocator);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
1549c6 | 1999-07-02 | Henrik Grubbström (Grubba) | |
|
a78643 | 1999-11-18 | Martin Stjernholm | |
|
b6f8c3 | 1999-07-01 | Henrik Grubbström (Grubba) | |
#ifdef COMPILER_DEBUG
|
a91d9a | 2016-01-11 | Martin Nilsson | | #define CDFPRINTF(...) fprintf(stderr, __VA_ARGS__)
|
9d8034 | 2013-08-14 | Marcus Comstedt | | #ifndef PIKE_THREADS
|
8b5b3a | 2014-04-28 | Henrik Grubbström (Grubba) | |
static const int lock_depth = 1;
|
9d8034 | 2013-08-14 | Marcus Comstedt | | #endif
|
b6f8c3 | 1999-07-01 | Henrik Grubbström (Grubba) | | #else /* !COMPILER_DEBUG */
|
a91d9a | 2016-01-11 | Martin Nilsson | | #define CDFPRINTF(...)
|
b6f8c3 | 1999-07-01 | Henrik Grubbström (Grubba) | | #endif /* COMPILER_DEBUG */
|
189fd0 | 1997-01-28 | Fredrik Hübinette (Hubbe) | | |
5985c1 | 2000-10-25 | Fredrik Hübinette (Hubbe) | | * These two values should probably be fine-tuned, but doing so
* more or less requires running a predictable 'typical' application
* and testing different hashsizes and tresholds. I tried to do it
* mathematically by measuring the extremes (no cache hits, 100%
* cache hits etc.) but it seems that the processor cache becomes
* exhausted in some of my measurements, which renders my mathematical
* model useless.
*
* Further measurements seems to indicate that this cache can slow
* things down a bit if the hit/miss rate is not fairly high.
* For normal applications, the hitrate is most likely well over 90%,
* but that should be verified.
|
11cd10 | 2015-11-30 | Martin Nilsson | | * - Hubbe
|
189fd0 | 1997-01-28 | Fredrik Hübinette (Hubbe) | | */
|
5985c1 | 2000-10-25 | Fredrik Hübinette (Hubbe) | |
|
b6e421 | 2012-05-21 | Per Hedbor | | #define FIND_FUNCTION_HASHSIZE 16384
|
5985c1 | 2000-10-25 | Fredrik Hübinette (Hubbe) | |
|
f1f7e7 | 2013-06-12 | Per Hedbor | | #define FIND_FUNCTION_HASH_TRESHOLD 0
|
189fd0 | 1997-01-28 | Fredrik Hübinette (Hubbe) | |
|
5c8e89 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | #define DECLARE
#include "compilation.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
cbe130 | 2017-01-06 | Henrik Grubbström (Grubba) | | struct pike_string *this_program_string, *this_string, *args_string;
|
6a2250 | 2014-09-30 | Per Hedbor | | static struct pike_string *this_function_string;
|
ebf5bb | 2004-09-18 | Per Hedbor | | static struct pike_string *UNDEFINED_string;
|
9e2686 | 1999-12-31 | Martin Stjernholm | |
|
94d66b | 2008-05-24 | Henrik Grubbström (Grubba) | |
struct pike_string *parser_system_string;
struct pike_string *type_check_system_string;
|
99682c | 2014-08-12 | Per Hedbor | |
|
ebf5bb | 2004-09-18 | Per Hedbor | | const char *const lfun_names[] = {
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | "__INIT",
"create",
|
4c583f | 2021-02-09 | Henrik Grubbström (Grubba) | | "\0_destruct\0destroy",
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | "_sprintf",
0,
"`+",
"`-",
"`*",
"`/",
"`%",
"`&",
"`|",
"`^",
"`<<",
"`>>",
"`**",
0,
"``+",
"``-",
|
056a64 | 2020-09-06 | Henrik Grubbström (Grubba) | | "``*",
"``/",
"``%",
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | "``&",
"``|",
"``^",
"``<<",
"``>>",
"``**",
0,
"`~",
"`!",
"`()",
"cast",
"__hash",
"_sqrt",
"_random",
"_reverse",
0,
"`==",
"`<",
"`>",
"_equal",
"_is_type",
0,
"`[]",
"`->",
"`[..]",
"_search",
"_size_object",
0,
"_sizeof",
"_indices",
"_values",
"_types",
"_annotations",
"_get_iterator",
0,
"`+=",
"`[]=",
"`->=",
"_m_delete",
"_m_clear",
"_m_add",
|
062499 | 2020-11-09 | Henrik Grubbström (Grubba) | | "_atomic_get_set",
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | 0,
"_serialize",
"_deserialize",
0,
|
4c583f | 2021-02-09 | Henrik Grubbström (Grubba) | | "\0_iterator_next\0next",
"\0_iterator_index\0index",
"\0_iterator_value\0value",
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | 0,
0,
|
558069 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | };
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | struct pike_string *lfun_strings[0x100];
|
096053 | 2020-11-20 | Henrik Grubbström (Grubba) | | struct pike_string *lfun_compat_strings[0x100];
|
286afb | 2001-02-05 | Henrik Grubbström (Grubba) | |
static struct mapping *lfun_ids;
|
51059b | 1999-12-26 | Henrik Grubbström (Grubba) | |
static struct mapping *lfun_types;
|
cae3cb | 2005-01-20 | Martin Nilsson | | static const char *const raw_lfun_types[] = {
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | tFuncV(tNone,tVoid,tVoid),
tFuncV(tNone,tZero,tVoid),
tFuncV(tOr(tVoid,tInt),tVoid,tInt01),
tFuncV(tInt tOr(tMap(tStr,tInt),tVoid),tVoid,tStr),
0,
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | tFuncV(tZero,tVoid,tMix),
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | tFunc(tOr(tVoid,tZero),tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tZero,tVoid,tMix),
tFuncV(tZero,tVoid,tMix),
tFuncV(tOr3(tInt,tFloat,tObj),tVoid,tOr3(tObj,tInt,tFloat)),
0,
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | tFuncV(tZero,tVoid,tMix),
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | tFuncV(tZero,tVoid,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tNone,tZero,tMix),
tFuncV(tZero,tVoid,tMix),
tFuncV(tZero,tVoid,tMix),
tFuncV(tOr3(tInt,tFloat,tObj),tVoid,tOr3(tObj,tInt,tFloat)),
0,
tFuncV(tNone,tVoid,tMix),
tFuncV(tNone,tVoid,tInt),
tFuncV(tNone,tZero,tMix),
tFuncV(tString,tVoid,tMix),
tFuncV(tNone,tVoid,tInt),
tFunc(tVoid,tMix),
tFuncV(tFunction tFunction, tVoid, tMix),
tFuncV(tNone, tOr(tZero, tVoid), tVoid),
0,
tFuncV(tMix,tVoid,tInt),
tFuncV(tMix,tVoid,tInt),
tFuncV(tMix,tVoid,tInt),
tFuncV(tMix,tVoid,tInt),
tFuncV(tStr,tVoid,tInt),
0,
tFuncV(tZero,tVoid,tMix),
tFuncV(tStr tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tMix),
tFuncV(tZero tRangeBound tZero tRangeBound, tVoid, tMix),
tFuncV(tZero tOr(tZero, tVoid), tZero, tMix),
tFuncV(tNone, tVoid, tInt),
0,
tFuncV(tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tInt),
tFuncV(tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tArray),
tFuncV(tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tArray),
tFuncV(tNone,tVoid,tArray),
tFuncV(tOr(tVoid,tObj) tOr(tVoid,tInt)
tOr(tInt01,tVoid),tVoid,tArray),
tFuncV(tNone,tVoid,tObj),
0,
|
f0a706 | 2022-01-03 | Henrik Grubbström (Grubba) | | tFuncV(tUnknown,tVoid,tMix),
tFuncV(tUnknown tSetvar(0,tMix) tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tVar(0)),
tFuncV(tLStr(tUnknown, tUnknown) tSetvar(0,tMix) tOr(tVoid,tObj) tOr(tVoid,tInt),tVoid,tVar(0)),
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | tFuncV(tZero,tVoid,tMix),
tFuncV(tNone, tVoid, tVoid),
tFuncV(tZero, tVoid, tVoid),
|
062499 | 2020-11-09 | Henrik Grubbström (Grubba) | | tFuncV(tZero tZero, tVoid, tMix),
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | 0,
tFuncV(tObj tZero, tVoid, tVoid),
tFuncV(tObj tZero, tVoid, tVoid),
0,
|
096053 | 2020-11-20 | Henrik Grubbström (Grubba) | | tFuncV(tNone, tZero, tMix),
tFuncV(tNone, tZero, tMix),
tFuncV(tNone, tZero, tMix),
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | 0,
0,
|
51059b | 1999-12-26 | Henrik Grubbström (Grubba) | | };
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | |
static struct pike_type *lfun_getter_type_string = NULL;
static struct pike_type *lfun_setter_type_string = NULL;
|
47251d | 2002-12-11 | Henrik Grubbström (Grubba) | | |
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *!
*! Callback functions used to overload various builtin functions.
*!
*! The functions can be grouped into a few sets:
*!
*! @ul
*! @item
*! Object initialization and destruction.
*!
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! @[__INIT()], @[create()], @[_destruct()]
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *!
*! @item
*! Unary operator overloading.
*!
*! @[`~()], @[`!()],
*! @[_values()], @[cast()],
*! @[_sizeof()], @[_indices()],
*! @[__hash()]
*!
*! @item
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Binary asymmetric operator overloading.
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *!
*! @[`+()], @[``+()],
*! @[`-()], @[``-()],
*! @[`&()], @[``&()],
*! @[`|()], @[``|()],
*! @[`^()], @[``^()],
*! @[`<<()], @[``<<()],
*! @[`>>()], @[``>>()],
*! @[`*()], @[``*()],
*! @[`/()], @[``/()],
*! @[`%()], @[``%()]
*!
*! @item
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Binary symmetric operator overloading.
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *!
*! The optimizer will make assumptions about the relations
*! between these functions.
*!
*! @[`==()], @[_equal()], @[`<()], @[`>()]
*!
*! @item
*! Other binary operator overloading.
*!
*! @[`[]()], @[`[]=()], @[`->()],
*! @[`->=()], @[`+=()], @[`()()]
*!
*! @item
*! Overloading of other builtin functions.
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[_is_type()], @[_sprintf()], @[_m_delete()],
|
142c80 | 2003-09-04 | Henrik Grubbström (Grubba) | | *! @[_get_iterator()], @[_search()]
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @endul
*!
*! @note
|
977987 | 2008-06-28 | Martin Stjernholm | | *! Although these functions are called from outside the object they
*! exist in, they will still be used even if they are declared
*! @expr{protected@}. It is in fact recommended to declare them
*! @expr{protected@}, since that will hinder them being used for
*! other purposes.
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *!
*! @seealso
*! @[::]
|
397e7d | 2001-10-28 | Martin Nilsson | | */
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Inherit and variable initialization.
*!
*! This function is generated automatically by the compiler. It's
*! called just before @[lfun::create()] when an object is
*! instantiated.
*!
*! It first calls any @expr{__INIT@} functions in inherited classes
*! (regardless of modifiers on the inherits). It then executes all
*! the variable initialization expressions in this class, in the
*! order they occur.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @note
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! This function can not be overloaded or blocked from executing.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
*! @[lfun::create()]
*/
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! Object creation callback.
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! This function is called right after @[lfun::__INIT()].
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @[args] are the arguments passed when the program was called.
|
269dd9 | 2001-05-23 | Henrik Grubbström (Grubba) | | *!
*! @note
|
e1aec8 | 2014-11-15 | Stephen R. van den Berg | | *! This function can be created implicitly
*! by the compiler using the syntax:
|
f79bd8 | 2003-04-01 | Martin Nilsson | | *! @code
*! class Foo(int foo) {
*! int bar;
*! }
*! @endcode
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! In the above case an implicit @[lfun::create()] is created, and
|
bf2c0d | 2018-01-12 | Stephen R. van den Berg | | *! it's equivalent to:
|
f79bd8 | 2003-04-01 | Martin Nilsson | | *! @code
*! class Foo {
*! int foo;
*! int bar;
|
977987 | 2008-06-28 | Martin Stjernholm | | *! protected void create(int foo)
|
f79bd8 | 2003-04-01 | Martin Nilsson | | *! {
|
b19a26 | 2017-02-01 | Henrik Grubbström (Grubba) | | *! this::foo = foo;
|
f79bd8 | 2003-04-01 | Martin Nilsson | | *! }
*! }
*! @endcode
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! @[lfun::__INIT()], @[lfun::_destruct()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! Object destruction callback.
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
09f288 | 2005-02-09 | Martin Stjernholm | | *! This function is called right before the object is destructed.
*! That can happen either through a call to @[predef::destruct()],
*! when there are no more references to the object, or when the
*! garbage collector discovers that it's part of a cyclic data
*! structure that has become garbage.
*!
*! @param reason
*! A flag that tells why the object is destructed:
*!
*! @int
*! @value Object.DESTRUCT_EXPLICIT
*! Destructed explicitly by @[predef::destruct].
*! @value Object.DESTRUCT_NO_REFS
*! Destructed due to running out of references.
*! @value Object.DESTRUCT_GC
*! Destructed by the garbage collector.
*! @value Object.DESTRUCT_CLEANUP
|
e7634f | 2007-05-13 | Martin Stjernholm | | *! Destructed as part of the cleanup when the pike process
*! exits. Occurs only if Pike has been compiled with the
*! configure option @tt{--with-cleanup-on-exit@}. See note
*! below.
|
09f288 | 2005-02-09 | Martin Stjernholm | | *! @endint
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
*! @note
|
e7634f | 2007-05-13 | Martin Stjernholm | | *! Objects are normally not destructed when a process exits, so
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! @expr{_destruct@} functions aren't called then. Use @[atexit] to get
|
e7634f | 2007-05-13 | Martin Stjernholm | | *! called when the process exits.
*!
*! @note
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Regarding destruction order during garbage collection:
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! If an object is destructed by the garbage collector, it's part of
*! a reference cycle with other things but with no external
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! references. If there are other objects with @expr{_destruct@}
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! functions in the same cycle, it becomes a problem which to call
*! first.
*!
*! E.g. if this object has a variable with another object which
*! (directly or indirectly) points back to this one, you might find
*! that the other object already has been destructed and the variable
*! thus contains zero.
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! The garbage collector tries to minimize such problems by defining
*! an order as far as possible:
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @ul
*! @item
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! If an object A contains an @[lfun::_destruct] and an object B does
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! not, then A is destructed before B.
*! @item
*! If A references B single way, then A is destructed before B.
*! @item
*! If A and B are in a cycle, and there is a reference somewhere
*! from B to A that is weaker than any reference from A to B, then
*! A is destructed before B.
*! @item
|
e7634f | 2007-05-13 | Martin Stjernholm | | *! If a cycle is resolved according to the rule above by ignoring a
*! weaker reference, and there is another ambiguous cycle that
*! would get resolved by ignoring the same reference, then the
*! latter cycle will be resolved by ignoring that reference.
*! @item
*! Weak references (e.g. set with @[predef::set_weak_flag()]) are
*! considered weaker than normal references, and both are
*! considered weaker than strong references.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @item
*! Strong references are those from objects to the objects of their
*! lexically surrounding classes. There can never be a cycle
*! consisting only of strong references. (This means the gc never
*! destructs a parent object before all children have been
*! destructed.)
*! @endul
|
13670c | 2015-05-25 | Martin Nilsson | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! An example with well defined destruct order due to strong
*! references:
*!
*! @code
*! class Super {
*! class Sub {
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! protected void _destruct() {
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! if (!Super::this)
*! error ("My parent has been destructed!\n");
*! }
*! }
*! Sub sub = Sub();
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! protected void _destruct() {
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! if (!sub)
*! werror ("sub already destructed.\n");
*! }
*! }
*! @endcode
*!
*! The garbage collector ensures that these objects are destructed in
*! an order so that @expr{werror@} in @expr{Super@} is called and not
*! @expr{error@} in @expr{Sub@}.
*!
*! @note
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! When the garbage collector calls @[lfun::_destruct], all accessible
*! non-objects and objects without @expr{_destruct@} functions are
*! still intact. They are not freed if the @expr{_destruct@} function
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! adds external references to them. However, all objects with
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | *! @[lfun::_destruct] in the cycle are already scheduled for
|
09f288 | 2005-02-09 | Martin Stjernholm | | *! destruction and will therefore be destroyed even if external
*! references are added to them.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::create()], @[predef::destruct()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side addition/concatenation callback.
*!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! This is used by @[predef::`+]. It's called with the argument
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! that follow this object in the argument list of the call to
*! @[predef::`+]. The returned value should be a new instance that
*! represents the addition/concatenation between this object and
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! the argument.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! @note
*! In versions of Pike prior to 8.1.10 this function could get
*! called with multiple arguments.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
5d9136 | 2003-04-18 | Martin Stjernholm | | *! @[lfun::``+()], @[lfun::`+=()], @[predef::`+()]
*/
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | |
5d9136 | 2003-04-18 | Martin Stjernholm | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Destructive addition/concatenation callback.
*!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! This is used by @[predef::`+]. It's called with the argument
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! that follow this object in the argument list of the call to
*! @[predef::`+]. It should update this object to represent the
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! addition/concatenation between it and the argument.
*! It should always return this object.
|
5d9136 | 2003-04-18 | Martin Stjernholm | | *!
*! @note
*! This function should only be implemented if @[lfun::`+()] also
*! is. It should only work as a more optimized alternative to that
*! one, for the case when it's safe to change the object
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! destructively and use it directly as the result.
|
5d9136 | 2003-04-18 | Martin Stjernholm | | *!
*! @note
*! This function is not an lfun for the @expr{+=@} operator. It's
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! only whether or not it's safe to do a destructive change that
*! decides if this function or @[lfun::`+()] is called; both the
|
5d9136 | 2003-04-18 | Martin Stjernholm | | *! @expr{+@} operator and the @expr{+=@} operator can call either
*! one.
*!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! @note
*! In versions of Pike prior to 8.1.10 this function could get
*! called with multiple arguments.
*!
|
5d9136 | 2003-04-18 | Martin Stjernholm | | *! @seealso
*! @[lfun::`+()], @[predef::`+()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Right side addition/concatenation callback.
*!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! This is used by @[predef::`+]. It's called with the sum of the
*! arguments that precede this object in the argument list of the
*! call to @[predef::`+]. The returned value should be a new
*! instance that represents the addition/concatenation between the
*! argument and this object.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
*! @note
*! It's assumed that this function is side-effect free.
*!
|
38af26 | 2021-03-17 | Henrik Grubbström (Grubba) | | *! @note
*! In versions of Pike prior to 8.1.10 this function could get
*! called with multiple arguments.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @seealso
*! @[lfun::`+()], @[predef::`+()]
*/
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``-()], @[predef::`-()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side bitwise and/intersection callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``&()], @[predef::`&()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side bitwise or/union callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``|()], @[predef::`|()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side exclusive or callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``^()], @[predef::`^()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side left shift callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``<<()], @[predef::`<<()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side right shift callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``>>()], @[predef::`>>()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side multiplication/repetition/implosion callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``*()], @[predef::`*()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side division/split callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``/()], @[predef::`/()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Left side modulo callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[lfun::``%()], @[predef::`%()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | |
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | |
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Complement/inversion callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::`~()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! Equivalence test callback.
*!
*! @returns
*! Is expected to return @expr{1@} if the current object is
*! equivalent to @[arg] (ie may be replaced with @[arg], with
*! no semantic differences (disregarding the effects of @[destruct()])),
*! and @expr{0@} (zero) otherwise.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *! @note
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! If this is implemented it may be necessary to implement
*! @[lfun::__hash] too. Otherwise mappings may hold several
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *! objects as indices which are duplicates according to this
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! function. This may also affect various other functions
*! that use hashing internally, e.g. @[predef::Array.uniq].
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
*!
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! @note
*! It's recommended to only implement this function for
*! immutable objects, as otherwise stuff may get confusing
*! when things that once were equivalent no longer are so,
*! or the reverse.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *! @[predef::`==()], @[lfun::__hash]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Less than test callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::`<()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Greater than test callback.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::`>()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! Hashing callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
e751c4 | 2010-05-19 | Henrik Grubbström (Grubba) | | *! The main caller of this function is @[predef::hash_value()]
|
bf2c0d | 2018-01-12 | Stephen R. van den Berg | | *! or the low-level equivalent, which get called by various
|
e751c4 | 2010-05-19 | Henrik Grubbström (Grubba) | | *! mapping operations when the object is used as index in a mapping.
*!
*! @returns
*! It should return an integer that corresponds to the object
*! in such a way that all values which @[lfun::`==] considers
*! equal to the object get the same hash value.
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *!
*! @note
*! The function @[predef::hash] does not return hash values that
*! are compatible with this one.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
*!
|
779ae1 | 2003-04-28 | Martin Stjernholm | | *! @seealso
|
e751c4 | 2010-05-19 | Henrik Grubbström (Grubba) | | *! @[lfun::`==], @[predef::hash_value()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Value cast callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! @param requested_type
*! Type to cast to.
*!
*! @returns
*! Expected to return the object value-casted (converted) to
*! the type described by @[requested_type].
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @note
|
317384 | 2001-12-20 | Martin Nilsson | | *! The argument is currently a string with the name
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! of the type, but might in the future be a value of the type type.
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *!
*! @note
|
317384 | 2001-12-20 | Martin Nilsson | | *! Currently casting between object types is a noop.
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *!
*! @note
*! If the returned value is not deemed to be of the requested type
*! a runtime error may be thrown.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
408a1e | 2004-10-30 | Martin Stjernholm | | *! Indexing callback.
*!
*! For compatibility, this is also called to do subranges unless
*! there is a @[`[..]] in the class. See @[predef::`[..]] for
*! details.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
408a1e | 2004-10-30 | Martin Stjernholm | | *! @[predef::`[]()], @[predef::`[..]]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | *! Atomic get and set index callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
6d6b8c | 2016-12-17 | Henrik Grubbström (Grubba) | | *! @param index
*! Index to change the value of.
*!
*! @param value
*! The new value.
*!
*! @param context
*! Context in the current object to index.
*!
*! If @expr{UNDEFINED@} or left out, @expr{this_program::this@}
*! is to be used (ie start at the current context and ignore
*! any overloaded symbols).
*!
*! @param access
*! Access permission override. One of the following:
*! @int
*! @value 0
*! @value UNDEFINED
*! See only public symbols.
*! @value 1
*! See protected symbols as well.
*! @endint
*!
*! This function is to set the value at index @[index] of the current
*! object to @[value].
*!
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | *! @returns
*! Returns the previous value at index @[index] of the current object.
*!
|
3d4599 | 2021-01-12 | Henrik Grubbström (Grubba) | | *! @note
*! In Pike 8.0 and earlier the return value of this function was
*! ignored.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
e4bdc5 | 2020-11-10 | Henrik Grubbström (Grubba) | | *! @[predef::`[]=()], @[lfun::`->=()], @[lfun::_atomic_get_set()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
4df620 | 2013-11-16 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Arrow index callback.
*!
|
4df620 | 2013-11-16 | Henrik Grubbström (Grubba) | | *! @param index
*! Symbol in @[context] to access.
*!
*! @param context
*! Context in the current object to start the search from.
*! If @expr{UNDEFINED@} or left out, @expr{this_program::this@}
*! is to be be used (ie start at the current context and ignore
*! any overloaded symbols).
*!
*! @param access
*! Access permission override. One of the following:
*! @int
*! @value 0
*! @value UNDEFINED
*! See only public symbols.
*! @value 1
*! See protected symbols as well.
*! @endint
*!
*! @returns
*! Returns the value at @[index] if it exists, and
*! @expr{UNDEFINED@} otherwise.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | *! @[predef::`->()], @[::`->()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | |
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | *! object|void context, int|void access)
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | *! Atomic get and set arrow index callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
4df620 | 2013-11-16 | Henrik Grubbström (Grubba) | | *! @param index
*! Symbol in @[context] to change the value of.
*!
*! @param value
*! The new value.
*!
*! @param context
|
6d6b8c | 2016-12-17 | Henrik Grubbström (Grubba) | | *! Context in the current object to index.
*!
|
4df620 | 2013-11-16 | Henrik Grubbström (Grubba) | | *! If @expr{UNDEFINED@} or left out, @expr{this_program::this@}
*! is to be used (ie start at the current context and ignore
*! any overloaded symbols).
*!
*! @param access
*! Access permission override. One of the following:
*! @int
*! @value 0
*! @value UNDEFINED
*! See only public symbols.
*! @value 1
*! See protected symbols as well.
*! @endint
*!
|
6d6b8c | 2016-12-17 | Henrik Grubbström (Grubba) | | *! This function is to set the value at symbol @[index] of the current
*! object to @[value].
|
4df620 | 2013-11-16 | Henrik Grubbström (Grubba) | | *!
|
976d4a | 2020-11-16 | Henrik Grubbström (Grubba) | | *! @returns
*! Returns the previous value at symbol @[index] of the current object.
*!
|
3d4599 | 2021-01-12 | Henrik Grubbström (Grubba) | | *! @note
*! In Pike 8.0 and earlier the return value of this function was
*! ignored.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
e4bdc5 | 2020-11-10 | Henrik Grubbström (Grubba) | | *! @[predef::`->=()], @[::`->=()], @[lfun::`[]=()],
*! @[lfun::_atomic_get_set()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
5d086e | 2001-05-05 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Size query callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
eaf089 | 2003-11-20 | Henrik Grubbström (Grubba) | | *! Called by @[predef::sizeof()] to determine the number of elements
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! in an object. If this function is not present, the number
*! of public symbols in the object will be returned.
*!
*! @returns
*! Expected to return the number of valid indices in the object.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::sizeof()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! List indices callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! @returns
*! Expected to return an array with the valid indices in the object.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | *! @[predef::indices()], @[lfun::_values()], @[lfun::_types()],
*! @[::_indices()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! List values callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! @returns
*! Expected to return an array with the values corresponding to
*! the indices returned by @[lfun::_indices()].
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | *! @[predef::values()], @[lfun::_indices()], @[lfun::_types()],
*! @[::_values()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
5d086e | 2001-05-05 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Apply callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::`()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! Type comparison callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! Called by the cast operator to determine if an object
*! simulates a basic type.
*!
*! @param basic_type
*! One of:
*! @string
*! @value "array"
*! @value "float"
*! @value "function"
*! @value "int"
*! @value "mapping"
*! @value "multiset"
*! @value "object"
*! @value "program"
*! @value "string"
*! @value "type"
*! @value "void"
*! @value "zero"
*! @endstring
*!
*! The following five shouldn't occurr, but are here for completeness:
*! @string
*! @value "lvalue"
*! @value "mapping_data"
*! @value "object storage"
*! @value "pike_frame"
*! @value "unknown"
*! @endstring
*!
*! @returns
|
cbe8c9 | 2003-04-07 | Martin Nilsson | | *! Expected to return @expr{1@} if the object is to be regarded as a
|
317384 | 2001-12-20 | Martin Nilsson | | *! simulation of the type specified by @[basic_type].
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @note
|
317384 | 2001-12-20 | Martin Nilsson | | *! The argument is currently a string with the name
|
f60f89 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! of the type, but might in the future be a value of the type type.
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *!
*! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
8203d4 | 2001-02-09 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *! Sprintf callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
14230c | 2003-01-03 | Henrik Grubbström (Grubba) | | *! This method is called by @[predef::sprintf()] to print objects. If it is
|
302b71 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! not present, printing of the object will not be supported for any
|
b77275 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! conversion-type except for the @tt{%O@}-conversion-type, which
|
cbe8c9 | 2003-04-07 | Martin Nilsson | | *! will output @expr{"object"@}.
|
b77275 | 2001-12-20 | Henrik Grubbström (Grubba) | | *!
*! @param conversion_type
*! One of:
*! @int
*! @value 'b'
*! Signed binary integer.
*! @value 'd'
*! Signed decimal integer.
*! @value 'u'
*! Unsigned decimal integer.
*! @value 'o'
*! Signed octal integer.
*! @value 'x'
*! Lowercase signed hexadecimal integer.
*! @value 'X'
*! Uppercase signed hexadecimal integer.
*! @value 'c'
*! Character. If a fieldsize has been specified this will output
*! the low-order bytes of the integer in network byte order.
*! @value 'f'
*! Float.
*! @value 'g'
*! Heuristically chosen representation of float.
*! @value 'G'
*! Like @tt{%g@}, but uses uppercase @tt{E@} for exponent.
*! @value 'e'
*! Exponential notation float.
*! @value 'E'
*! Like @tt{%e@}, but uses uppercase @tt{E@} for exponent.
*! @value 's'
*! String.
*! @value 'O'
*! Any value (debug style).
*! @value 't'
*! Type of the argument.
*! @endint
*!
*! @param params
*! Conversion parameters. The following parameters may be supplied:
*! @mapping
*! @member int "precision"
*! Precision.
*! @member int "width"
*! Field width.
*! @member int(1..1) "flag_left"
*! Indicates that the output should be left-aligned.
*! @member int "indent"
*! Indentation level in @tt{%O@}-mode.
*! @endmapping
*!
*! @returns
*! Is expected to return a string describing the object formatted
*! according to @[conversion_type].
*!
*! @note
|
317384 | 2001-12-20 | Martin Nilsson | | *! @[_sprintf()] is currently not called for the following
|
b77275 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! conversion-types:
*! @int
*! @value 'F'
|
13670c | 2015-05-25 | Martin Nilsson | | *! Binary IEEE representation of float (@tt{%4F@} gives
|
b77275 | 2001-12-20 | Henrik Grubbström (Grubba) | | *! single precision, @tt{%8F@} gives double precision.)
*! @endint
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! This function might be called at odd times, e.g. before
*! @[lfun::create] has been called or when an error has occurred.
*! The reason is typically that it gets called when a backtrace is
*! being formatted to report an error. It should therefore be very
*! robust and not make any assumptions about its own internal
*! state, at least not when @[conversion_type] is @expr{'O'@}.
*!
*! @note
*! It's assumed that this function is side-effect free.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::sprintf()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
8203d4 | 2001-02-09 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Recursive equality callback.
*!
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! @returns
*! Is expected to return @expr{1@} if the current object is
*! equal to @[arg], and @expr{0@} (zero) otherwise.
*!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! @note
*! It's assumed that this function is side-effect free.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
ebe4bc | 2015-03-13 | Henrik Grubbström (Grubba) | | *! @note
*! Note that this function may return different values at different
*! times for the same argument due to the mutability of the object.
*!
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::equal()], @[lfun::`==()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
8203d4 | 2001-02-09 | Henrik Grubbström (Grubba) | | |
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Delete index callback.
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | *!
*! @seealso
|
dd2c60 | 2002-12-20 | Henrik Grubbström (Grubba) | | *! @[predef::m_delete()]
|
1a5b2f | 2001-02-09 | Henrik Grubbström (Grubba) | | */
|
44c7da | 2019-04-11 | Henrik Grubbström (Grubba) | | |
226d64 | 2001-02-24 | Henrik Grubbström (Grubba) | | *!
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! Iterator creation callback.
*!
|
44c7da | 2019-04-11 | Henrik Grubbström (Grubba) | | *! @param args
*! Optional extra arguments as passed to @[get_iterator()].
*! The implicit call from @[foreach()] does not provide any arguments.
*!
|
eaf089 | 2003-11-20 | Henrik Grubbström (Grubba) | | *! The returned @[predef::Iterator] instance works as a cursor that
|
dfceb0 | 2003-11-10 | Martin Stjernholm | | *! references a specific item contained (in some arbitrary sense)
*! in this one.
*!
*! @note
*! It's assumed that this function is side-effect free.
|
83c261 | 2001-05-05 | Henrik Grubbström (Grubba) | | *!
|
c4131e | 2003-04-18 | Martin Stjernholm | | *! @seealso
|
eaf089 | 2003-11-20 | Henrik Grubbström (Grubba) | | *! @[predef::Iterator], @[predef::get_iterator], @[predef::foreach()]
|
226d64 | 2001-02-24 | Henrik Grubbström (Grubba) | | */
|
abb3e4 | 2013-11-18 | Henrik Grubbström (Grubba) | |
|
fcf741 | 2016-11-04 | Tobias S. Josefowitz | | |
8a7676 | 2016-10-12 | Henrik Grubbström (Grubba) | | *! mixed ... extra_args)
|
142c80 | 2003-09-04 | Henrik Grubbström (Grubba) | | *!
*! Search callback.
*!
|
8a7676 | 2016-10-12 | Henrik Grubbström (Grubba) | | *! The arguments are sent straight from @[search()], and are
*! as follows:
*!
*! @param needle
*! Value to search for.
*!
*! @param start
*! The first position to search.
*!
*! @param extra_args
*! Optional extra arguments as passed to @[search()].
*!
|
142c80 | 2003-09-04 | Henrik Grubbström (Grubba) | | *! @seealso
*! @[predef::search()]
*/
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | |
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | *!
*! List types callback.
*!
*! This callback is typically called via @[predef::types()].
*!
*! @returns
*! Expected to return an array with the types corresponding to
*! the indices returned by @[lfun::_indices()].
*!
*! @note
*! It's assumed that this function is side-effect free.
*!
*! @note
*! @[predef::types()] was added in Pike 7.9.
*!
*! @seealso
*! @[predef::types()], @[lfun::_indices()], @[lfun::_values()],
*! @[::_types()]
*/
|
103136 | 2011-01-21 | Henrik Grubbström (Grubba) | | |
9cded8 | 2011-02-04 | Henrik Grubbström (Grubba) | | *! function(mixed, string, type:void) serializer)
|
103136 | 2011-01-21 | Henrik Grubbström (Grubba) | | *!
*! Dispatch function for @[Serializer.serialize()].
*!
*! @param o
*! Object to serialize. Always a context of the current object.
*!
*! @param serializer
*! Function to be called once for every variable
*! to serialize.
*!
*! The @[serializer] function expects to be called with three arguments:
*! @dl
*! @item
|
9cded8 | 2011-02-04 | Henrik Grubbström (Grubba) | | *! @tt{value@} - The value of the symbol.
*! @item
|
103136 | 2011-01-21 | Henrik Grubbström (Grubba) | | *! @tt{symbol@} - The symbol name.
*! @item
*! @tt{symbol_type@} - The type of the symbol.
*! @enddl
*!
*! @note
*! A default implementation of @[lfun::_serialize()] and
*! @[lfun::_deserialize()] is available in @[Serializer.Serializable].
*!
*! @seealso
*! @[lfun::_deserialize()], @[Serializer.serialize()],
*! @[Serializer.Serializable()->_serialize()]
*/
|
9cded8 | 2011-02-04 | Henrik Grubbström (Grubba) | | *! function(function(mixed:void), @
*! string, type: mixed) deserializer)
|
103136 | 2011-01-21 | Henrik Grubbström (Grubba) | | *!
*! Dispatch function for @[Serialization.deserialize()].
*!
*! @param o
*! Object to serialize. Always a context of the current object.
*!
*! @param deserializer
*! Function to be called once for every variable
*! to serialize.
*!
*! The @[deserializer] function expects to be called with three arguments:
*! @dl
*! @item
|
9cded8 | 2011-02-04 | Henrik Grubbström (Grubba) | | *! @tt{setter@} - Function that sets the symbol value.
*! @item
|
103136 | 2011-01-21 | Henrik Grubbström (Grubba) | | *! @tt{symbol@} - The symbol name.
*! @item
*! @tt{symbol_type@} - The type of the symbol.
*! @enddl
*!
*! @note
*! A default implementation of @[lfun::_serialize()] and
*! @[lfun::_deserialize()] is available in @[Serializer.Serializable].
*!
*! @seealso
*! @[lfun::_serialize()], @[Serializer.deserialize()],
*! @[Serializer.Serializable()->_deserialize()]
*/
|
f9aaee | 2013-11-18 | Henrik Grubbström (Grubba) | |
|
705e61 | 2016-03-13 | Henrik Grubbström (Grubba) | | |
e24c3d | 2013-11-18 | Henrik Grubbström (Grubba) | | *! Called by @[random()]. Typical use is when the object implements
*! a ADT, when a call to this lfun should return a random member of
*! the ADT or range implied by the ADT.
*!
|
705e61 | 2016-03-13 | Henrik Grubbström (Grubba) | | *! @param random_string
*! A @[RandomInterface()->random_string] function that returns
*! a string(8bit) of the specified length.
*!
*! @param random
*! A @[RandomInterface()->random] function.
*!
|
e24c3d | 2013-11-18 | Henrik Grubbström (Grubba) | | *! @seealso
|
705e61 | 2016-03-13 | Henrik Grubbström (Grubba) | | *! @[predef::random()], @[RandomInterface]
|
e24c3d | 2013-11-18 | Henrik Grubbström (Grubba) | | */
|
3b2a92 | 2018-12-03 | Henrik Grubbström (Grubba) | |
|
4664e1 | 2018-12-08 | Henrik Grubbström (Grubba) | | |
ecb8ff | 2019-01-27 | Henrik Grubbström (Grubba) | | *! @seealso
|
4664e1 | 2018-12-08 | Henrik Grubbström (Grubba) | | *! @[lfun::_m_delete()], @[lfun::_m_add()]
*/
|
a47e4f | 2019-02-01 | Tobias S. Josefowitz | | |
a17061 | 2018-12-09 | Henrik Grubbström (Grubba) | | *!
*! Called by @[m_add()].
*!
*! @seealso
*! @[lfun::_m_delete()], @[lfun::_m_clear()]
*/
|
bb3640 | 2019-11-20 | Henrik Grubbström (Grubba) | |
|
74346f | 2021-01-11 | Henrik Grubbström (Grubba) | |
|
e4bdc5 | 2020-11-10 | Henrik Grubbström (Grubba) | |
|
74346f | 2021-01-11 | Henrik Grubbström (Grubba) | | |
e4bdc5 | 2020-11-10 | Henrik Grubbström (Grubba) | | *!
*! Get and set the value for an index atomically.
*!
*! @param index
*! Index for which to get and set the value.
*!
*! @param value
*! Value to set.
*!
*! @returns
*! Returns the previous value at index @[index].
*!
*! @seealso
*! @[lfun::`->=()], @[lfun::`[]=()], @[atomic_get_set()],
*! @[lfun::_m_delete()], @[lfun::`[]()], @[lfun::`->()]
*/
|
abb3e4 | 2013-11-18 | Henrik Grubbström (Grubba) | |
|
d25a89 | 2007-11-15 | Henrik Grubbström (Grubba) | | |
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | *!
*! Variable retrieval callback (aka "getter").
*!
*! @note
*! Note that the @expr{symbol@} in the name can be any symbol.
*!
*! @note
*! This is not a true LFUN, since it is even more low level!
*!
*! @note
*! This function WILL be called even by inheriting programs
*! when they attempt to access the variable named @expr{symbol@}.
*!
*! @seealso
*! @[lfun::`->symbol=()], @[lfun::`->()]
*/
|
d25a89 | 2007-11-15 | Henrik Grubbström (Grubba) | | |
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | *!
*! Variable assignment callback (aka "setter").
*!
*! @note
*! Note that the @expr{symbol@} in the name can be any symbol.
*!
*! @note
*! This is not a true LFUN, since it is even more low level!
*!
*! @note
*! This function WILL be called even by inheriting programs
*! when they attempt to set the variable named @expr{symbol@}.
*!
*! @seealso
*! @[lfun::`->symbol()], @[lfun::`->=()]
*/
|
47251d | 2002-12-11 | Henrik Grubbström (Grubba) | |
|
193795 | 2002-12-08 | Henrik Grubbström (Grubba) | |
|
cbe8c9 | 2003-04-07 | Martin Nilsson | | *! Returns the default module, or @expr{0@} (zero).
|
193795 | 2002-12-08 | Henrik Grubbström (Grubba) | | *!
|
cbe8c9 | 2003-04-07 | Martin Nilsson | | *! If @expr{0@} (zero) is returned the compiler use the mapping
|
193795 | 2002-12-08 | Henrik Grubbström (Grubba) | | *! returned by @[all_constants()] as fallback.
*!
*! @seealso
*! @[get_predefines()]
*/
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | struct program *first_program = 0;
|
f8d8f4 | 2001-07-01 | Henrik Grubbström (Grubba) | | static int current_program_id = PROG_DYNAMIC_ID_START;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | struct program *gc_internal_program = 0;
static struct program *gc_mark_program_pos = 0;
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | #define CHECK_FILE_ENTRY(PROG, STRNO) \
|
1415ff | 2003-03-19 | Martin Stjernholm | | do { \
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | if ((STRNO < 0) || (STRNO >= PROG->num_strings)) \
|
1415ff | 2003-03-19 | Martin Stjernholm | | Pike_fatal ("Invalid file entry in linenumber info.\n"); \
} while (0)
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE get_small_number(char **q);
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | |
|
f13b95 | 2006-07-05 | Martin Stjernholm | | PMOD_EXPORT void do_free_program (struct program *p)
{
if (p)
free_program(p);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
1bc319 | 2004-01-16 | Martin Nilsson | | #define CHECK_FOO(NUMTYPE,TYPE,NAME) \
if(Pike_compiler->malloc_size_program-> PIKE_CONCAT(num_,NAME) < \
Pike_compiler->new_program-> PIKE_CONCAT(num_,NAME)) \
Pike_fatal("Pike_compiler->new_program->num_" #NAME " is out of order\n");\
if(Pike_compiler->new_program->flags & PROGRAM_OPTIMIZED) \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Tried to reallocate fixed program.\n")
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
#else
#define CHECK_FOO(NUMTYPE,TYPE,NAME)
#endif
|
0e0cd7 | 2001-07-20 | Henrik Grubbström (Grubba) | | #ifndef RELOCATE_program
#define RELOCATE_program(ORIG, NEW)
#endif /* !RELOCATE_program */
|
b61bd9 | 2009-03-04 | Henrik Grubbström (Grubba) | | #define RELOCATE_identifier_cache(ORIG,NEW)
|
302ede | 2001-07-19 | Henrik Grubbström (Grubba) | | #define RELOCATE_linenumbers(ORIG,NEW)
#define RELOCATE_identifier_index(ORIG,NEW)
#define RELOCATE_variable_index(ORIG,NEW)
#define RELOCATE_identifier_references(ORIG,NEW)
#define RELOCATE_strings(ORIG,NEW)
#define RELOCATE_inherits(ORIG,NEW)
#define RELOCATE_identifiers(ORIG,NEW)
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | #define RELOCATE_annotations(ORIG,NEW)
|
302ede | 2001-07-19 | Henrik Grubbström (Grubba) | | #define RELOCATE_constants(ORIG,NEW)
#define RELOCATE_relocations(ORIG,NEW)
|
6c8749 | 2004-01-16 | Mirar (Pontus Hagland) | | #if SIZEOF_LONG_LONG == 8
#define MAXVARS(NUMTYPE) \
(NUMTYPE)(sizeof(NUMTYPE)==1?254: \
(sizeof(NUMTYPE)==2?65534: \
(sizeof(NUMTYPE)==4?4294967294U:18446744073709551614ULL)))
#else
#define MAXVARS(NUMTYPE) \
(NUMTYPE)(sizeof(NUMTYPE)==1?254: (sizeof(NUMTYPE)==2?65534:4294967294U))
#endif
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #ifdef PIKE_USE_MACHINE_CODE
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | * machine code. For decoding efficiency we also want a multi copy
* variant to be used by decode().
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | */
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #if !defined(HAVE_PTHREAD_JIT_WRITE_PROTECT_NP) && !defined(pthread_jit_write_protect_np)
|
0afd7f | 2021-01-04 | Marcus Comstedt | | #define pthread_jit_write_protect_np(enable) do{}while(0)
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #endif
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \
void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \
TYPE ARG) { \
NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \
CHECK_FOO(NUMTYPE,TYPE,NAME); \
if(m == state->new_program->PIKE_CONCAT(num_,NAME)) { \
TYPE *tmp; \
if(m==MAXVARS(NUMTYPE)) { \
yyerror("Too many " #NAME "."); \
return; \
} \
m = MINIMUM(m*2+1,MAXVARS(NUMTYPE)); \
|
557242 | 2014-04-27 | Martin Nilsson | | tmp = mexec_realloc(state->new_program->NAME, sizeof(TYPE) * m); \
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | if(!tmp) Pike_fatal("Out of memory.\n"); \
PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \
state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \
state->new_program->NAME=tmp; \
} \
|
c11f16 | 2021-01-04 | Marcus Comstedt | | pthread_jit_write_protect_np(0); \
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | state->new_program-> \
NAME[state->new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \
|
c11f16 | 2021-01-04 | Marcus Comstedt | | pthread_jit_write_protect_np(1); \
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | } \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | void PIKE_CONCAT(low_add_many_to_,NAME) (struct program_state *state, \
TYPE *ARG, NUMTYPE cnt) { \
NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \
CHECK_FOO(NUMTYPE,TYPE,NAME); \
if((m + cnt) > state->new_program->PIKE_CONCAT(num_,NAME)) { \
TYPE *tmp; \
NUMTYPE n = m; \
do { \
if(n==MAXVARS(NUMTYPE)) { \
yyerror("Too many " #NAME "."); \
return; \
} \
|
b3d326 | 2009-08-18 | Henrik Grubbström (Grubba) | | n = MINIMUM(n*2+1,MAXVARS(NUMTYPE)); \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | } while (m + cnt > n); \
m = n; \
|
557242 | 2014-04-27 | Martin Nilsson | | tmp = mexec_realloc(state->new_program->NAME, sizeof(TYPE) * m); \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | if(!tmp) Pike_fatal("Out of memory.\n"); \
PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \
state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \
state->new_program->NAME=tmp; \
} \
|
c11f16 | 2021-01-04 | Marcus Comstedt | | pthread_jit_write_protect_np(0); \
|
59fc9e | 2014-09-03 | Martin Nilsson | | memcpy(state->new_program->NAME + \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | state->new_program->PIKE_CONCAT(num_,NAME), \
ARG, sizeof(TYPE) * cnt); \
|
c11f16 | 2021-01-04 | Marcus Comstedt | | pthread_jit_write_protect_np(1); \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | state->new_program->PIKE_CONCAT(num_,NAME) += cnt; \
} \
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | void PIKE_CONCAT(add_to_,NAME) (ARGTYPE ARG) { \
PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \
}
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | #else /* !PIKE_USE_MACHINE_CODE */
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \
FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
void PIKE_CONCAT(low_add_many_to_,NAME) (struct program_state *state, \
TYPE *ARG, NUMTYPE cnt) { \
NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \
CHECK_FOO(NUMTYPE,TYPE,NAME); \
if((m + cnt) > state->new_program->PIKE_CONCAT(num_,NAME)) { \
TYPE *tmp; \
NUMTYPE n = m; \
do { \
if(n==MAXVARS(NUMTYPE)) { \
yyerror("Too many " #NAME "."); \
return; \
} \
|
b3d326 | 2009-08-18 | Henrik Grubbström (Grubba) | | n = MINIMUM(n*2+1,MAXVARS(NUMTYPE)); \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | } while (m + cnt > n); \
m = n; \
|
557242 | 2014-04-27 | Martin Nilsson | | tmp = realloc(state->new_program->NAME, sizeof(TYPE) * m); \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | if(!tmp) Pike_fatal("Out of memory.\n"); \
PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \
state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \
state->new_program->NAME=tmp; \
} \
|
59fc9e | 2014-09-03 | Martin Nilsson | | memcpy(state->new_program->NAME + \
|
e18a68 | 2009-08-17 | Henrik Grubbström (Grubba) | | state->new_program->PIKE_CONCAT(num_,NAME), \
ARG, sizeof(TYPE) * cnt); \
state->new_program->PIKE_CONCAT(num_,NAME) += cnt; \
}
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #endif /* PIKE_USE_MACHINE_CODE */
|
1bc319 | 2004-01-16 | Martin Nilsson | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \
TYPE ARG) { \
|
1bc319 | 2004-01-16 | Martin Nilsson | | NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \
CHECK_FOO(NUMTYPE,TYPE,NAME); \
if(m == state->new_program->PIKE_CONCAT(num_,NAME)) { \
|
302ede | 2001-07-19 | Henrik Grubbström (Grubba) | | TYPE *tmp; \
|
50a98f | 2004-01-19 | Henrik Grubbström (Grubba) | | if(m==MAXVARS(NUMTYPE)) { \
|
a0b06e | 2004-01-19 | Henrik Grubbström (Grubba) | | yyerror("Too many " #NAME "."); \
|
50a98f | 2004-01-19 | Henrik Grubbström (Grubba) | | return; \
} \
m = MINIMUM(m*2+1,MAXVARS(NUMTYPE)); \
|
557242 | 2014-04-27 | Martin Nilsson | | tmp = realloc(state->new_program->NAME, sizeof(TYPE) * m); \
|
7ed496 | 2002-11-19 | Henrik Grubbström (Grubba) | | if(!tmp) Pike_fatal("Out of memory.\n"); \
|
84abc6 | 2007-10-13 | Henrik Grubbström (Grubba) | | PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \
state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \
state->new_program->NAME=tmp; \
} \
state->new_program-> \
NAME[state->new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \
} \
void PIKE_CONCAT(add_to_,NAME) (ARGTYPE ARG) { \
PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \
}
#define PASS1ONLY(NUMTYPE,TYPE,ARGTYPE,NAME) \
void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \
TYPE ARG) { \
NUMTYPE m = state->malloc_size_program->PIKE_CONCAT(num_,NAME); \
CHECK_FOO(NUMTYPE,TYPE,NAME); \
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | DO_IF_DEBUG(if (state->compiler_pass != COMPILER_PASS_FIRST) { \
|
84abc6 | 2007-10-13 | Henrik Grubbström (Grubba) | | Pike_fatal("Adding " TOSTR(NAME) " in pass %d.\n", \
state->compiler_pass); \
}); \
if(m == state->new_program->PIKE_CONCAT(num_,NAME)) { \
TYPE *tmp; \
if(m==MAXVARS(NUMTYPE)) { \
yyerror("Too many " #NAME "."); \
return; \
} \
m = MINIMUM(m*2+1,MAXVARS(NUMTYPE)); \
|
557242 | 2014-04-27 | Martin Nilsson | | tmp = realloc(state->new_program->NAME, sizeof(TYPE) * m); \
|
84abc6 | 2007-10-13 | Henrik Grubbström (Grubba) | | if(!tmp) Pike_fatal("Out of memory.\n"); \
|
302ede | 2001-07-19 | Henrik Grubbström (Grubba) | | PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \
|
1bc319 | 2004-01-16 | Martin Nilsson | | state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | state->new_program->NAME=tmp; \
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | } \
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | state->new_program-> \
NAME[state->new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \
} \
|
7e877a | 2003-04-02 | Martin Stjernholm | | void PIKE_CONCAT(add_to_,NAME) (ARGTYPE ARG) { \
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | |
#include "program_areas.h"
|
7ed496 | 2002-11-19 | Henrik Grubbström (Grubba) | | #define add_to_program(ARG) do { \
debug_malloc_touch(Pike_compiler->new_program->program); \
add_to_program(ARG); \
} while(0)
|
87ed09 | 2019-03-17 | Tobias S. Josefowitz | | void ins_int(INT32 i, void (*func)(unsigned char tmp))
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
int e;
|
573ba4 | 2001-04-11 | Henrik Grubbström (Grubba) | | unsigned char *p = (unsigned char *)&i;
for(e=0;e<(long)sizeof(i);e++) {
func(p[e]);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
5f8eb7 | 1997-02-18 | Fredrik Hübinette (Hubbe) | |
|
2449d2 | 2008-05-10 | Martin Stjernholm | | #if 0
|
5ec106 | 2002-05-09 | Martin Stjernholm | | static void debug_add_to_identifiers (struct identifier id)
{
if (d_flag) {
int i;
for (i = 0; i < Pike_compiler->new_program->num_identifiers; i++)
if (Pike_compiler->new_program->identifiers[i].name == id.name) {
dump_program_tables (Pike_compiler->new_program, 0);
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | Pike_fatal ("Adding identifier twice, old at %s:%d #%d.\n",
Pike_compiler->new_program->identifiers[i].filename?
Pike_compiler->new_program->identifiers[i].filename:"-",
Pike_compiler->new_program->identifiers[i].linenumber,
i);
|
5ec106 | 2002-05-09 | Martin Stjernholm | | }
}
add_to_identifiers (id);
}
#else
#define debug_add_to_identifiers(ARG) add_to_identifiers(ARG)
#endif
|
3da1ab | 2017-02-13 | Henrik Grubbström (Grubba) | | static int low_add_identifier(struct compilation *c,
struct pike_type *type,
struct pike_string *name,
unsigned int identifier_flags,
unsigned int opt_flags,
union idptr func,
int run_time_type)
|
ac77f9 | 2017-02-10 | Henrik Grubbström (Grubba) | | {
struct identifier dummy;
|
3da1ab | 2017-02-13 | Henrik Grubbström (Grubba) | | int n = Pike_compiler->new_program->num_identifiers;
|
ac77f9 | 2017-02-10 | Henrik Grubbström (Grubba) | | copy_shared_string(dummy.name, name);
copy_pike_type(dummy.type, type);
dummy.filename_strno = store_prog_string(c->lex.current_file);
dummy.linenumber = c->lex.current_line;
dummy.identifier_flags = identifier_flags;
dummy.run_time_type = run_time_type;
dummy.func = func;
dummy.opt_flags = opt_flags;
#ifdef PROFILING
dummy.self_time=0;
dummy.num_calls=0;
dummy.recur_depth=0;
dummy.total_time=0;
#endif
debug_add_to_identifiers(dummy);
|
3da1ab | 2017-02-13 | Henrik Grubbström (Grubba) | |
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | if (Pike_compiler->current_annotations) {
|
d5f68a | 2018-11-14 | Henrik Grubbström (Grubba) | |
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | compiler_add_annotations(n, Pike_compiler->current_annotations);
|
d5f68a | 2018-11-14 | Henrik Grubbström (Grubba) | |
free_node(Pike_compiler->current_annotations);
Pike_compiler->current_annotations = NULL;
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | }
|
3da1ab | 2017-02-13 | Henrik Grubbström (Grubba) | | return n;
}
static int add_identifier(struct compilation *c,
struct pike_type *type,
struct pike_string *name,
unsigned int modifier_flags,
unsigned int identifier_flags,
unsigned int opt_flags,
union idptr func,
int run_time_type)
{
struct reference ref;
struct identifier dummy;
int n;
if (modifier_flags & ID_PRIVATE) modifier_flags |= ID_LOCAL|ID_PROTECTED;
if (((identifier_flags & (IDENTIFIER_VARIABLE|IDENTIFIER_ALIAS)) ==
IDENTIFIER_VARIABLE) &&
(modifier_flags & ID_WEAK)) {
identifier_flags |= IDENTIFIER_WEAK;
}
ref.id_flags = modifier_flags;
ref.identifier_offset =
low_add_identifier(c, type, name,
identifier_flags, opt_flags,
func, run_time_type);
ref.inherit_offset = 0;
ref.run_time_type = PIKE_T_UNKNOWN;
if ((identifier_flags & (IDENTIFIER_VARIABLE|IDENTIFIER_ALIAS)) ==
IDENTIFIER_VARIABLE) {
add_to_variable_index(ref.identifier_offset);
}
n = Pike_compiler->new_program->num_identifier_references;
add_to_identifier_references(ref);
return n;
|
ac77f9 | 2017-02-10 | Henrik Grubbström (Grubba) | | }
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | void add_relocated_int_to_program(INT32 i)
{
add_to_relocations(Pike_compiler->new_program->num_program);
|
87ed09 | 2019-03-17 | Tobias S. Josefowitz | | ins_int(i, add_to_program);
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | }
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | void use_module(struct svalue *s)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if( (1<<TYPEOF(*s)) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))
|
5c0a10 | 1997-02-06 | Fredrik Hübinette (Hubbe) | | {
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->num_used_modules++;
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->num_used_modules++;
|
5c0a10 | 1997-02-06 | Fredrik Hübinette (Hubbe) | | assign_svalue_no_free((struct svalue *)
|
2d10fb | 2016-12-29 | Arne Goedeke | | buffer_alloc(&c->used_modules, sizeof(struct svalue)), s);
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->module_index_cache)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_mapping(Pike_compiler->module_index_cache);
Pike_compiler->module_index_cache=0;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
|
518b04 | 2011-11-20 | Henrik Grubbström (Grubba) | | if(c->resolve_cache)
{
free_mapping(c->resolve_cache);
c->resolve_cache=0;
}
|
5c0a10 | 1997-02-06 | Fredrik Hübinette (Hubbe) | | }else{
yyerror("Module is neither mapping nor object");
}
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | void unuse_modules(INT32 howmany)
{
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
756374 | 2016-11-08 | Arne Goedeke | | struct svalue *s = buffer_dst(&c->used_modules);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(!howmany) return;
|
756374 | 2016-11-08 | Arne Goedeke | | s -= howmany;
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
756374 | 2016-11-08 | Arne Goedeke | | if(howmany *sizeof(struct svalue) > buffer_content_length(&c->used_modules))
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Unusing too many modules.\n");
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | #endif
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->num_used_modules -= howmany;
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->num_used_modules-=howmany;
|
756374 | 2016-11-08 | Arne Goedeke | | free_svalues(s, howmany, BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM);
buffer_remove(&c->used_modules, howmany*sizeof(struct svalue));
#ifdef PIKE_DEBUG
if (s != buffer_dst(&c->used_modules))
Pike_fatal("buffer_remove is broken.\n");
#endif
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->module_index_cache)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_mapping(Pike_compiler->module_index_cache);
Pike_compiler->module_index_cache=0;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
}
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | |
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | static struct node_s *index_modules(struct pike_string *ident,
struct mapping **module_index_cache,
|
52af79 | 2014-10-22 | Arne Goedeke | | const int num_used_modules,
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | struct svalue *modules)
|
52af79 | 2014-10-22 | Arne Goedeke | | |
7aee46 | 2016-07-23 | Henrik Grubbström (Grubba) | | * modified in between setjmp() and longjmp(). This prevents -Wclobbered warnings.
|
52af79 | 2014-10-22 | Arne Goedeke | | */
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | if(*module_index_cache)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | struct svalue *tmp=low_mapping_string_lookup(*module_index_cache,ident);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(tmp)
{
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(!(SAFE_IS_ZERO(tmp) && SUBTYPEOF(*tmp)==1))
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | return mksvaluenode(tmp);
return 0;
}
}
|
8aae6d | 1999-08-19 | Fredrik Hübinette (Hubbe) | |
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | JMP_BUF tmp;
if(SETJMP(tmp))
|
910bd1 | 2008-05-30 | Martin Stjernholm | | handle_compile_exception ("Couldn't index a module with %S.", ident);
else {
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | int e = num_used_modules;
struct svalue *m = modules - num_used_modules;
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | while(--e>=0)
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | push_svalue(m+e);
ref_push_string(ident);
f_index(2);
if(!IS_UNDEFINED(Pike_sp-1))
{
struct node_s *ret;
UNSETJMP(tmp);
|
bd537b | 2002-12-10 | Martin Stjernholm | |
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST &&
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&
|
bd537b | 2002-12-10 | Martin Stjernholm | | Pike_sp[-1].u.object == placeholder_object) ||
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
|
bd537b | 2002-12-10 | Martin Stjernholm | | Pike_sp[-1].u.program == placeholder_program))) {
|
ce060e | 2004-06-30 | Martin Nilsson | | my_yyerror("Got placeholder %s (resolver problem) "
"when indexing a module with %S.",
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | get_name_of_type (TYPEOF(Pike_sp[-1])), ident);
|
bd537b | 2002-12-10 | Martin Stjernholm | | ret = 0;
}
else {
if(!*module_index_cache)
*module_index_cache = allocate_mapping(10);
mapping_string_insert(*module_index_cache, ident, Pike_sp-1);
ret = mksvaluenode(Pike_sp-1);
}
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | pop_stack();
return ret;
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_stack();
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
}
|
8fa310 | 2000-09-05 | Henrik Grubbström (Grubba) | | UNSETJMP(tmp);
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | |
|
8aae6d | 1999-08-19 | Fredrik Hübinette (Hubbe) | |
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
f34f64 | 2002-05-05 | Martin Stjernholm | | struct node_s *resolve_identifier(struct pike_string *ident);
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | struct node_s *find_module_identifier(struct pike_string *ident,
int see_inherit)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | struct node_s *ret;
|
756374 | 2016-11-08 | Arne Goedeke | | struct svalue *modules=(struct svalue *)buffer_dst(&c->used_modules);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | |
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | {
|
4d51e0 | 2002-06-10 | Martin Stjernholm | | struct program_state *p=Pike_compiler;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | int n;
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | for(n=0;n<=c->compilation_depth;n++,p=p->previous)
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | {
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | int i;
if(see_inherit)
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | {
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | i=really_low_find_shared_string_identifier(ident,
p->new_program,
|
653093 | 2008-06-29 | Martin Nilsson | | SEE_PROTECTED|SEE_PRIVATE);
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | if(i!=-1)
{
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | if ((p->flags & COMPILATION_FORCE_RESOLVE) &&
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | (p->compiler_pass == COMPILER_PASS_LAST) &&
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | ((p->num_inherits + 1) < p->new_program->num_inherits) &&
(PTR_FROM_INT(p->new_program, i)->inherit_offset >
p->num_inherits)) {
|
3b15fb | 2008-05-03 | Henrik Grubbström (Grubba) | | |
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | */
continue;
}
|
4d51e0 | 2002-06-10 | Martin Stjernholm | | return p == Pike_compiler ?
mkidentifiernode(i) :
mkexternalnode(p->new_program, i);
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | }
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
|
13670c | 2015-05-25 | Martin Nilsson | |
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | if((ret=index_modules(ident,
&p->module_index_cache,
p->num_used_modules,
modules))) return ret;
modules-=p->num_used_modules;
#ifdef PIKE_DEBUG
|
756374 | 2016-11-08 | Arne Goedeke | | if( ((char *)modules ) < (char*)buffer_ptr(&c->used_modules))
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Modules out of whack!\n");
|
4d7b18 | 1999-12-07 | Fredrik Hübinette (Hubbe) | | #endif
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
}
|
5be76b | 2005-08-10 | Henrik Grubbström (Grubba) | | return resolve_identifier(ident);
}
|
1ae555 | 2017-02-01 | Henrik Grubbström (Grubba) | |
struct node_s *find_predef_identifier(struct pike_string *ident)
{
struct compilation *c = THIS_COMPILATION;
node *tmp = mkconstantsvaluenode(&c->default_module);
node *ret = index_node(tmp, "predef", ident);
if(ret && !ret->name)
add_ref(ret->name = ident);
free_node(tmp);
return ret;
}
|
5be76b | 2005-08-10 | Henrik Grubbström (Grubba) | |
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | int low_resolve_identifier(struct pike_string *ident)
|
5be76b | 2005-08-10 | Henrik Grubbström (Grubba) | | {
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
node *ret = NULL;
|
e8d37d | 2002-02-14 | Henrik Grubbström (Grubba) | |
if (ident == UNDEFINED_string) {
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | push_undefined();
return 1;
|
e8d37d | 2002-02-14 | Henrik Grubbström (Grubba) | | }
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | |
|
518b04 | 2011-11-20 | Henrik Grubbström (Grubba) | | if(c->resolve_cache)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
518b04 | 2011-11-20 | Henrik Grubbström (Grubba) | | struct svalue *tmp=low_mapping_string_lookup(c->resolve_cache,ident);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(tmp)
{
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | if(IS_UNDEFINED (tmp)) {
return 0;
}
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | |
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | push_svalue(tmp);
return 1;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
}
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | CHECK_COMPILER();
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | ref_push_string(ident);
|
2a2b5c | 2018-07-07 | Henrik Grubbström (Grubba) | | if (!safe_apply_current2(PC_RESOLV_FUN_NUM, 1, NULL))
|
315271 | 2008-08-17 | Martin Stjernholm | | handle_compile_exception ("Error resolving '%S'.", ident);
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass != COMPILER_PASS_LAST) {
|
315271 | 2008-08-17 | Martin Stjernholm | |
struct program *p = NULL;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if (TYPEOF(Pike_sp[-1]) == T_PROGRAM)
|
315271 | 2008-08-17 | Martin Stjernholm | | p = Pike_sp[-1].u.program;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | else if (TYPEOF(Pike_sp[-1]) == T_OBJECT ||
(TYPEOF(Pike_sp[-1]) == T_FUNCTION &&
SUBTYPEOF(Pike_sp[-1]) != FUNCTION_BUILTIN))
|
315271 | 2008-08-17 | Martin Stjernholm | | p = Pike_sp[-1].u.object->prog;
if (p && !(p->flags & PROGRAM_PASS_1_DONE))
report_compiler_dependency (p);
}
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | |
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass == COMPILER_PASS_LAST &&
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | Pike_sp[-1].u.object == placeholder_object) ||
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | Pike_sp[-1].u.program == placeholder_program))) {
my_yyerror("Got placeholder %s (resolver problem) "
|
315271 | 2008-08-17 | Martin Stjernholm | | "when resolving '%S'.",
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | get_name_of_type (TYPEOF(Pike_sp[-1])), ident);
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | } else {
|
518b04 | 2011-11-20 | Henrik Grubbström (Grubba) | | if(!c->resolve_cache)
c->resolve_cache=dmalloc_touch(struct mapping *, allocate_mapping(10));
mapping_string_insert(c->resolve_cache,ident,Pike_sp-1);
|
8d697e | 2004-03-13 | Henrik Grubbström (Grubba) | |
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | if(!IS_UNDEFINED (Pike_sp-1))
{
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | return 1;
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | }
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | }
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | pop_stack();
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
4c5d26 | 2017-02-19 | Henrik Grubbström (Grubba) | | return 0;
}
struct node_s *resolve_identifier(struct pike_string *ident)
{
node *ret = NULL;
if (low_resolve_identifier(ident)) {
ret = mkconstantsvaluenode(Pike_sp-1);
pop_stack();
}
|
0ae461 | 2008-04-14 | Henrik Grubbström (Grubba) | | return ret;
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | }
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
ef2adb | 2013-04-21 | Henrik Grubbström (Grubba) | | * 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;
|
a4fcc4 | 2017-02-25 | Henrik Grubbström (Grubba) | | if (low_resolve_identifier(ident)) {
if ((ret = program_from_svalue(Pike_sp-1))) {
|
ef2adb | 2013-04-21 | Henrik Grubbström (Grubba) | | add_ref(ret);
}
|
a4fcc4 | 2017-02-25 | Henrik Grubbström (Grubba) | | pop_stack();
}
if (!ret) {
my_yyerror("Invalid program identifier '%S'.", ident);
|
ef2adb | 2013-04-21 | Henrik Grubbström (Grubba) | | }
return ret;
}
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | |
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | * -1 local::
* -2 global::
* -3 ::
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | */
struct node_s *find_inherited_identifier(struct program_state *inherit_state,
int inherit_depth, int inh,
struct pike_string *ident)
{
int id;
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | struct program *p = inherit_state->new_program;
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | |
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | #if 0
fprintf(stderr, "find_inherited_identifier(%p, %d, %d, \"%s\")\n",
inherit_state, inherit_depth, inh, ident->str);
#endif /* 0 */
|
4f6c97 | 2019-06-11 | Henrik Grubbström (Grubba) | | if (!p) {
return NULL;
}
|
baa771 | 2016-05-06 | Henrik Grubbström (Grubba) | | if (inh == INHERIT_ALL) {
|
c2e096 | 2016-05-02 | Henrik Grubbström (Grubba) | |
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | struct node_s *res = NULL;
for (inh = 1; inh < p->num_inherits; inh++) {
|
aaa36a | 2016-05-05 | Henrik Grubbström (Grubba) | | struct node_s *n;
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | if (p->inherits[inh].inherit_level != 1) continue;
|
c2e096 | 2016-05-02 | Henrik Grubbström (Grubba) | |
id = low_reference_inherited_identifier(inherit_state, inh, ident,
SEE_PROTECTED);
if (id == -1) continue;
|
aaa36a | 2016-05-05 | Henrik Grubbström (Grubba) | | if (inherit_depth) {
n = mkexternalnode(inherit_state->new_program, id);
} else {
n = mkidentifiernode(id);
}
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | if (res) {
|
aaa36a | 2016-05-05 | Henrik Grubbström (Grubba) | | res = mknode(F_ARG_LIST, res, n);
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | } else {
|
aaa36a | 2016-05-05 | Henrik Grubbström (Grubba) | | res = n;
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | }
}
if (res) {
if (res->token == F_ARG_LIST) res = mkefuncallnode("aggregate", res);
return res;
}
inh = -1;
} else {
if (inh > 0) {
id = low_reference_inherited_identifier(inherit_state, inh, ident,
SEE_PROTECTED);
} else {
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | |
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | id = really_low_find_shared_string_identifier(ident,
inherit_state->new_program,
SEE_PROTECTED|SEE_PRIVATE);
}
if (id != -1) {
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | if (inh == INHERIT_LOCAL) {
struct reference *ref = p->identifier_references + id;
if (IDENTIFIER_IS_VARIABLE(ID_FROM_PTR(p, ref)->identifier_flags)) {
yyerror ("Cannot make local references to variables.");
return NULL;
}
if (!(ref->id_flags & ID_LOCAL)) {
int d;
struct reference funp = *ref;
funp.id_flags = (funp.id_flags & ~ID_INHERITED) | ID_INLINE|ID_HIDDEN;
id = -1;
for(d = 0; d < (int)p->num_identifier_references; d++) {
struct reference *refp;
refp = p->identifier_references + d;
if (!(refp->id_flags & ID_LOCAL)) continue;
if((refp->inherit_offset == funp.inherit_offset) &&
(refp->identifier_offset == funp.identifier_offset)) {
id = d;
break;
}
}
if (id < 0) {
low_add_to_identifier_references(inherit_state, funp);
id = p->num_identifier_references - 1;
}
}
}
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | if (inherit_depth > 0) {
return mkexternalnode(inherit_state->new_program, id);
}
return mkidentifiernode(id);
}
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | if (inh < 0) inh = -1;
|
54bc86 | 2016-05-02 | Henrik Grubbström (Grubba) | | }
return program_magic_identifier(inherit_state, inherit_depth, inh, ident, 1);
}
|
561431 | 2002-11-17 | Henrik Grubbström (Grubba) | | |
88e9fb | 2003-08-03 | Martin Stjernholm | | *! Builtin read only variable that evaluates to the current object.
|
561431 | 2002-11-17 | Henrik Grubbström (Grubba) | | *!
*! @seealso
*! @[this_program], @[this_object()]
*/
|
c92b8e | 2016-05-06 | Henrik Grubbström (Grubba) | |
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
0ee38f | 2002-05-11 | Martin Stjernholm | | * like "this", "this_program" or "`->" when preceded by ::, then a
|
388e5d | 2008-05-30 | Henrik Grubbström (Grubba) | | * suitable node is returned, NULL otherwise.
*
|
c92b8e | 2016-05-06 | Henrik Grubbström (Grubba) | | * @param state
* Program state containing the inherit (if any), otherwise the
* current program state.
*
* @param state_depth
* Number of lexical scopes to the inherit state.
*
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | * @param inherit_num
* Inherit number in state->new_program that the identifier has been
* qualified with. -1 when no specific inherit has been specified; ie
* either when the identifier has no prefix (colon_colon_ref == 0) or
* when the identifier has the prefix :: without any preceding identifier
* (colon_colon_ref == 1).
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | *
|
c92b8e | 2016-05-06 | Henrik Grubbström (Grubba) | | * @param ident
* Identifier to look up.
*
* @param colon_colon_ref
* Boolean indicating whether state, state_depth and inherit_num
* should be regarded (1) or not (0).
*
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | * New in Pike 7.9.5 and later:
*
* If colon_colon_ref is 1 and the selected inherit defines the
* `->() lfun, code calling the lfun will be generated as follows:
*
* inh::`->(ident, inh::this, 1)
|
c92b8e | 2016-05-06 | Henrik Grubbström (Grubba) | | *
* New in Pike 8.1.4 and later:
*
* The symbol this_function may be prefixed with a selected inherit.
* It will then refer to the symbol with the same name as the
* current function from the selected inherit.
*
|
388e5d | 2008-05-30 | Henrik Grubbström (Grubba) | | */
|
0ee38f | 2002-05-11 | Martin Stjernholm | | struct node_s *program_magic_identifier (struct program_state *state,
int state_depth, int inherit_num,
|
9fca41 | 2017-07-31 | Martin Nilsson | | struct pike_string *ident,
|
0ee38f | 2002-05-11 | Martin Stjernholm | | int colon_colon_ref)
{
#if 0
|
f352fe | 2017-01-28 | Henrik Grubbström (Grubba) | | fprintf (stderr, "magic_identifier (state, %d, %d, \"%s\", %d)\n",
|
0ee38f | 2002-05-11 | Martin Stjernholm | | state_depth, inherit_num, ident->str, colon_colon_ref);
#endif
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | if (ident == this_string) {
return mkthisnode(state->new_program, inherit_num);
}
|
0ee38f | 2002-05-11 | Martin Stjernholm | |
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | |
if (ident == this_program_string) {
node *n;
if (!state_depth && (inherit_num == -1) && colon_colon_ref &&
!TEST_COMPAT(7,8) &&
state->previous && state->previous->new_program) {
struct program *parent;
struct pike_string *name = NULL;
int e;
int i;
parent = state->previous->new_program;
for (e = parent->num_identifier_references; e--;) {
struct identifier *id = ID_FROM_INT(parent, e);
struct svalue *s;
if (!IDENTIFIER_IS_CONSTANT(id->identifier_flags) ||
(id->func.const_info.offset < 0)) {
continue;
|
0f9107 | 2013-04-27 | Henrik Grubbström (Grubba) | | }
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | s = &PROG_FROM_INT(parent, e)->
constants[id->func.const_info.offset].sval;
if ((TYPEOF(*s) != T_PROGRAM) ||
(s->u.program != state->new_program)) {
continue;
|
0f9107 | 2013-04-27 | Henrik Grubbström (Grubba) | | }
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | |
name = id->name;
break;
}
if (!name) {
yyerror("Failed to find current class in its parent.");
return NULL;
}
|
0f9107 | 2013-04-27 | Henrik Grubbström (Grubba) | |
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | |
|
baa771 | 2016-05-06 | Henrik Grubbström (Grubba) | | n = find_inherited_identifier(state->previous, state_depth+1,
INHERIT_ALL, name);
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | if (!n) {
my_yyerror("Failed to find previous inherited definition of %S "
"in parent.", name);
return NULL;
|
0f9107 | 2013-04-27 | Henrik Grubbström (Grubba) | | }
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | } else {
n = mkefuncallnode("object_program",
mkthisnode(state->new_program, inherit_num));
|
88e9fb | 2003-08-03 | Martin Stjernholm | | }
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | |
n->node_info &= ~OPT_NOT_CONST;
n->tree_info &= ~OPT_NOT_CONST;
return n;
}
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | |
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | |
if (ident == this_function_string) {
int i;
if ((i = Pike_compiler->compiler_frame->current_function_number) >= 0) {
struct identifier *id;
id = ID_FROM_INT(Pike_compiler->new_program, i);
if (colon_colon_ref) {
|
baa771 | 2016-05-06 | Henrik Grubbström (Grubba) | | if (inherit_num == -1) inherit_num = INHERIT_ALL;
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | return find_inherited_identifier(state, state_depth, inherit_num,
id->name);
}
if (id->identifier_flags & IDENTIFIER_SCOPED) {
return mktrampolinenode(i, Pike_compiler->compiler_frame->previous);
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | } else {
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | return mkidentifiernode(i);
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | }
|
3c357e | 2016-05-06 | Henrik Grubbström (Grubba) | | } else {
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | }
|
0ee38f | 2002-05-11 | Martin Stjernholm | | }
if (colon_colon_ref) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | int i = inherit_num;
|
0ee38f | 2002-05-11 | Martin Stjernholm | |
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | if (inherit_num < 0) i = 0;
|
0ee38f | 2002-05-11 | Martin Stjernholm | | if(ident == lfun_strings[LFUN_ARROW] ||
ident == lfun_strings[LFUN_INDEX]) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | return mknode(F_MAGIC_INDEX, mknewintnode(i),
|
0ee38f | 2002-05-11 | Martin Stjernholm | | mknewintnode(state_depth));
} else if(ident == lfun_strings[LFUN_ASSIGN_ARROW] ||
ident == lfun_strings[LFUN_ASSIGN_INDEX]) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | return mknode(F_MAGIC_SET_INDEX, mknewintnode(i),
|
0ee38f | 2002-05-11 | Martin Stjernholm | | mknewintnode(state_depth));
} else if(ident == lfun_strings[LFUN__INDICES]) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | return mknode(F_MAGIC_INDICES, mknewintnode(i),
|
0ee38f | 2002-05-11 | Martin Stjernholm | | mknewintnode(state_depth));
} else if(ident == lfun_strings[LFUN__VALUES]) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | return mknode(F_MAGIC_VALUES, mknewintnode(i),
|
0ee38f | 2002-05-11 | Martin Stjernholm | | mknewintnode(state_depth));
|
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | } else if(ident == lfun_strings[LFUN__TYPES]) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | return mknode(F_MAGIC_TYPES, mknewintnode(i),
|
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | mknewintnode(state_depth));
|
6c22d2 | 2018-12-19 | Henrik Grubbström (Grubba) | | } else if(ident == lfun_strings[LFUN__ANNOTATIONS]) {
return mknode(F_MAGIC_ANNOTATIONS, mknewintnode(i),
mknewintnode(state_depth));
|
0ee38f | 2002-05-11 | Martin Stjernholm | | }
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | |
if (inherit_num && !TEST_COMPAT(7, 8) &&
(state->new_program->num_inherits > 1)) {
int id;
struct program *prog = state->new_program->inherits[i].prog;
if (((id = FIND_LFUN(prog, LFUN_ARROW)) == -1) &&
(prog == state->new_program)) {
id = really_low_find_shared_string_identifier(lfun_strings[LFUN_ARROW],
prog,
SEE_PROTECTED|SEE_PRIVATE);
} else if ((id != -1) && (prog != state->new_program)) {
id = really_low_reference_inherited_identifier(state, i, id);
}
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if ((id != -1) && (state->compiler_pass == COMPILER_PASS_LAST)) {
|
4bd520 | 2012-04-29 | Henrik Grubbström (Grubba) | | if (inherit_num < 0) {
struct inherit *inherits = state->new_program->inherits;
inherit_num = PTR_FROM_INT(state->new_program, id)->inherit_offset;
while (inherits[inherit_num].inherit_level > 1) {
inherit_num--;
}
}
return mknode(F_APPLY, mkexternalnode(state->new_program, id),
mknode(F_ARG_LIST,
mkstrnode(ident),
mknode(F_ARG_LIST,
mkthisnode(state->new_program, inherit_num),
mkintnode(1))));
}
}
|
0ee38f | 2002-05-11 | Martin Stjernholm | | }
return NULL;
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | struct program *parent_compilation(int level)
{
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | int n;
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | struct program_state *p=Pike_compiler->previous;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | for(n=0;n<level;n++)
{
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | if(n>=c->compilation_depth) return 0;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | p=p->previous;
if(!p) return 0;
}
return p->new_program;
}
#define ID_TO_PROGRAM_CACHE_SIZE 512
struct program *id_to_program_cache[ID_TO_PROGRAM_CACHE_SIZE];
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | struct program *id_to_program(INT32 id)
{
|
fa93a5 | 2008-02-28 | Henrik Grubbström (Grubba) | | struct program_state *state;
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | | struct program *p;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | INT32 h;
if(!id) return 0;
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | h=id & (ID_TO_PROGRAM_CACHE_SIZE-1);
if((p=id_to_program_cache[h]))
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | | if(p->id==id) {
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | return p;
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | | }
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | for(p=first_program;p;p=p->next)
{
if(id==p->id)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | id_to_program_cache[h]=p;
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | |
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | return p;
}
}
|
fa93a5 | 2008-02-28 | Henrik Grubbström (Grubba) | |
for (state = Pike_compiler; state; state = state->previous) {
if (state->new_program && state->new_program->id == id) {
return state->new_program;
}
}
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | if ((id > 0) && (id < PROG_DYNAMIC_ID_START)) {
char *module = NULL;
|
c0fdd6 | 2016-11-07 | Henrik Grubbström (Grubba) | | DECLARE_CYCLIC();
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | |
|
c0fdd6 | 2016-11-07 | Henrik Grubbström (Grubba) | | if (!BEGIN_CYCLIC(((ptrdiff_t)id), 0)) {
SET_CYCLIC_RET(1);
switch(id) {
case PROG_PARSER_HTML_ID:
module = "Parser._parser";
break;
case PROG_GMP_MPZ_ID:
module = "Gmp";
break;
case PROG_MODULE_MIME_ID:
module = "___MIME";
break;
default:
if ((id >= 100) && (id < 300)) {
module = "Image";
} else if ((id >= 300) && (id < 400)) {
module = "Nettle";
} else if ((id >= 1000) && (id < 2000)) {
module = "___GTK1";
} else if ((id >= 2000) && (id < 3000)) {
module = "___GTK2";
}
break;
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | }
}
|
c0fdd6 | 2016-11-07 | Henrik Grubbström (Grubba) | |
|
0e2c51 | 2009-08-18 | Henrik Grubbström (Grubba) | | if (module && get_master()) {
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | |
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | push_text(module);
SAFE_APPLY_MASTER("resolv", 1);
pop_stack();
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | for(p=first_program;p;p=p->next)
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | {
if(id==p->id)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | id_to_program_cache[h]=p;
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | |
|
c0fdd6 | 2016-11-07 | Henrik Grubbström (Grubba) | | END_CYCLIC();
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | return p;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
c0fdd6 | 2016-11-07 | Henrik Grubbström (Grubba) | | END_CYCLIC();
|
a38237 | 2001-07-02 | Henrik Grubbström (Grubba) | | }
|
f84d28 | 2004-12-08 | Henrik Grubbström (Grubba) | |
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
6f9669 | 2009-09-12 | Henrik Grubbström (Grubba) | | |
13670c | 2015-05-25 | Martin Nilsson | | * optimize_program ==> PROGRAM_OPTIMIZED
|
6f9669 | 2009-09-12 | Henrik Grubbström (Grubba) | | *
* end_first_pass(1) ==> PROGRAM_FINISHED
*/
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | void optimize_program(struct program *p)
{
|
080b1a | 2000-08-10 | Henrik Grubbström (Grubba) | | size_t size=0;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | char *data;
if(p->flags & PROGRAM_OPTIMIZED) return;
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #ifdef PIKE_USE_MACHINE_CODE
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME)
|
13670c | 2015-05-25 | Martin Nilsson | | #endif /* PIKE_USE_MACHINE_CODE */
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | size=DO_ALIGN(size, ALIGNOF(TYPE)); \
size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
data=malloc(size);
|
13670c | 2015-05-25 | Martin Nilsson | | if(!data)
|
f82226 | 2001-07-16 | Fredrik Hübinette (Hubbe) | | {
make_program_executable(p);
return;
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
size=0;
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #ifdef PIKE_USE_MACHINE_CODE
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME)
|
13670c | 2015-05-25 | Martin Nilsson | | #endif /* PIKE_USE_MACHINE_CODE */
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | size=DO_ALIGN(size, ALIGNOF(TYPE)); \
|
37cd45 | 2003-06-09 | Martin Stjernholm | | if (p->PIKE_CONCAT (num_, NAME)) \
|
59fc9e | 2014-09-03 | Martin Nilsson | | memcpy(data+size,p->NAME,p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0])); \
|
302ede | 2001-07-19 | Henrik Grubbström (Grubba) | | PIKE_CONCAT(RELOCATE_,NAME)(p, (TYPE *)(data+size)); \
|
193795 | 2002-12-08 | Henrik Grubbström (Grubba) | | dmfree(p->NAME); \
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | p->NAME=(TYPE *)(data+size); \
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
p->total_size=size + sizeof(struct program);
p->flags |= PROGRAM_OPTIMIZED;
|
f82226 | 2001-07-16 | Fredrik Hübinette (Hubbe) | | make_program_executable(p);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
828815 | 2003-06-30 | Martin Stjernholm | | static int program_identifier_index_compare(int a, int b,
const struct program *p)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
828815 | 2003-06-30 | Martin Stjernholm | | size_t val_a = PTR_TO_INT (ID_FROM_INT(p, a)->name);
size_t val_b = PTR_TO_INT (ID_FROM_INT(p, b)->name);
|
2fb986 | 2008-09-04 | Henrik Grubbström (Grubba) | | return val_a < val_b ? -1 : (val_a == val_b ? (a < b? -1:(a != b)) : 1);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
ab9db5 | 2003-02-20 | Henrik Grubbström (Grubba) | | #define CMP(X,Y) program_identifier_index_compare(*(X), *(Y), prog)
#define EXTRA_ARGS , struct program *prog
#define XARGS , prog
#define ID fsort_program_identifier_index
#define TYPE unsigned short
#include "fsort_template.h"
#undef TYPE
#undef ID
#undef XARGS
#undef EXTRA_ARGS
#undef CMP
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | struct pike_string *find_program_name(struct program *p, INT_TYPE *line)
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | {
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE l;
|
cd8632 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | if(!line) line=&l;
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | |
#ifdef DEBUG_MALLOC
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | {
|
ce3d2f | 2014-10-01 | Martin Nilsson | | const char *tmp=dmalloc_find_name(p);
|
a275d2 | 2003-03-29 | Martin Stjernholm | | if (tmp) {
|
5aa54c | 2014-09-03 | Martin Nilsson | | char *p = strchr (tmp, ':');
|
a275d2 | 2003-03-29 | Martin Stjernholm | | if (p) {
char *pp;
|
5aa54c | 2014-09-03 | Martin Nilsson | | while ((pp = strchr (p + 1, ':'))) p = pp;
|
a275d2 | 2003-03-29 | Martin Stjernholm | | *line = atoi (p + 1);
return make_shared_binary_string (tmp, p - tmp);
}
else {
*line=0;
return make_shared_string(tmp);
}
}
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | }
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | #endif
|
4f985f | 2001-06-30 | Martin Stjernholm | | return get_program_line(p, line);
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | }
#endif
|
aaf40c | 2013-11-03 | Henrik Grubbström (Grubba) | | int override_identifier (struct reference *new_ref, struct pike_string *name,
int required_flags)
|
5ec106 | 2002-05-09 | Martin Stjernholm | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | int id = -1, cur_id = 0, is_used = 0;
|
c2060d | 2003-06-06 | Henrik Grubbström (Grubba) | |
int new_is_variable =
IDENTIFIER_IS_VARIABLE(ID_FROM_PTR(Pike_compiler->new_program,
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | new_ref)->identifier_flags);
|
c2060d | 2003-06-06 | Henrik Grubbström (Grubba) | |
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | CHECK_COMPILER();
|
5ec106 | 2002-05-09 | Martin Stjernholm | | for(;cur_id<Pike_compiler->new_program->num_identifier_references;cur_id++)
{
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | struct reference *ref =
Pike_compiler->new_program->identifier_references + cur_id;
struct identifier *i;
if (ref == new_ref) continue;
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | if(ref->id_flags & ID_HIDDEN) continue;
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
2c740d | 2013-05-26 | Henrik Grubbström (Grubba) | | if(ref->id_flags & ID_VARIANT) continue;
|
aaf40c | 2013-11-03 | Henrik Grubbström (Grubba) | | if ((ref->id_flags & required_flags) != required_flags) continue;
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | if((i = ID_FROM_PTR(Pike_compiler->new_program, ref))->name != name)
|
5ec106 | 2002-05-09 | Martin Stjernholm | | continue;
|
b3d326 | 2009-08-18 | Henrik Grubbström (Grubba) | |
if((ref->id_flags & (ID_INLINE|ID_INHERITED)) == (ID_INLINE|ID_INHERITED)
|| (ref->id_flags & new_ref->id_flags & ID_EXTERN)) {
|
fcaec3 | 2008-09-14 | Henrik Grubbström (Grubba) | |
ref->id_flags |= ID_HIDDEN;
continue;
}
|
5ec106 | 2002-05-09 | Martin Stjernholm | | #ifdef PROGRAM_BUILD_DEBUG
|
8411e5 | 2017-01-28 | Henrik Grubbström (Grubba) | | fprintf(stderr, "%*soverloaded reference %d (id_flags:0x%04x)\n",
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth, "", cur_id, ref->id_flags);
|
5ec106 | 2002-05-09 | Martin Stjernholm | | #endif
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | if (!new_is_variable && IDENTIFIER_IS_VARIABLE(i->identifier_flags)) {
|
fa6afc | 2003-06-06 | Henrik Grubbström (Grubba) | |
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | ref->id_flags |= ID_INLINE|ID_HIDDEN;
|
ce060e | 2004-06-30 | Martin Nilsson | | yywarning("Attempt to override a non local variable %S "
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | "with a non-variable.", name);
|
c2060d | 2003-06-06 | Henrik Grubbström (Grubba) | | continue;
}
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | if ((ref->id_flags & (ID_INHERITED|ID_USED)) == (ID_INHERITED|ID_USED)) {
struct inherit *inh = INHERIT_FROM_PTR(Pike_compiler->new_program, ref);
struct reference *sub_ref;
while (inh->inherit_level > 1) inh--;
|
c2a952 | 2013-06-08 | Henrik Grubbström (Grubba) | | #if 0
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
if (!inh->inherit_level) {
|
c2a952 | 2013-06-08 | Henrik Grubbström (Grubba) | |
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | Pike_fatal("Inherit without intermediate levels.\n");
}
|
c2a952 | 2013-06-08 | Henrik Grubbström (Grubba) | | #endif
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | #endif
sub_ref = PTR_FROM_INT(inh->prog, cur_id - inh->identifier_level);
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | if ((c->lex.pragmas & ID_STRICT_TYPES) &&
|
9d9c33 | 2021-03-29 | Henrik Grubbström (Grubba) | | (Pike_compiler->compiler_pass == COMPILER_PASS_LAST) &&
|
6f25b5 | 2007-10-12 | Henrik Grubbström (Grubba) | | (sub_ref->id_flags & ID_USED)) {
|
30893e | 2007-10-12 | Henrik Grubbström (Grubba) | | struct identifier *sub_id = ID_FROM_PTR(inh->prog, sub_ref);
if (IDENTIFIER_IS_FUNCTION(sub_id->identifier_flags)) {
|
9d9c33 | 2021-03-29 | Henrik Grubbström (Grubba) | | if (!pike_types_le(ID_FROM_PTR(Pike_compiler->new_program,
|
ff8572 | 2021-03-22 | Henrik Grubbström (Grubba) | | new_ref)->type, sub_id->type, 0, 0)) {
|
94d66b | 2008-05-24 | Henrik Grubbström (Grubba) | | yytype_report(REPORT_WARNING,
NULL, 0, sub_id->type,
NULL, 0, ID_FROM_PTR(Pike_compiler->new_program,
new_ref)->type,
0, "Type mismatch when overloading function %S.",
name);
|
30893e | 2007-10-12 | Henrik Grubbström (Grubba) | | }
} else {
|
01c479 | 2008-02-03 | Henrik Grubbström (Grubba) | | struct identifier *new_id;
|
8e488c | 2008-02-03 | Henrik Grubbström (Grubba) | | * Note: Use weaker check for integers (especially for constants).
|
01c479 | 2008-02-03 | Henrik Grubbström (Grubba) | | */
|
30893e | 2007-10-12 | Henrik Grubbström (Grubba) | | if (!pike_types_le(sub_id->type,
|
01c479 | 2008-02-03 | Henrik Grubbström (Grubba) | | (new_id = ID_FROM_PTR(Pike_compiler->new_program,
|
ff8572 | 2021-03-22 | Henrik Grubbström (Grubba) | | new_ref))->type, 0, 0) &&
|
01c479 | 2008-02-03 | Henrik Grubbström (Grubba) | | !((i->run_time_type == PIKE_T_INT) &&
(new_id->run_time_type == PIKE_T_INT) &&
|
8e488c | 2008-02-03 | Henrik Grubbström (Grubba) | | (IDENTIFIER_IS_CONSTANT(sub_id->identifier_flags) ||
match_types(sub_id->type, new_id->type)))) {
|
94d66b | 2008-05-24 | Henrik Grubbström (Grubba) | | yytype_report(REPORT_WARNING,
NULL, 0, sub_id->type,
NULL, 0, new_id->type,
0, "Type mismatch when overloading %S.", name);
|
30893e | 2007-10-12 | Henrik Grubbström (Grubba) | | }
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | }
}
}
is_used = ref->id_flags & ID_USED;
*ref=*new_ref;
ref->id_flags |= is_used;
|
5ec106 | 2002-05-09 | Martin Stjernholm | | id = cur_id;
}
return id;
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | void fixate_program(void)
{
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | INT32 i,e,t;
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | struct program *p=Pike_compiler->new_program;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | CHECK_COMPILER();
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | if(p->flags & PROGRAM_FIXED) return;
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | if(p->flags & PROGRAM_OPTIMIZED)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Cannot fixate optimized program\n");
|
6169c7 | 2021-02-12 | Henrik Grubbström (Grubba) | |
for (i = 0; i < p->num_identifier_references; i++) {
struct reference *ref = p->identifier_references + i;
struct identifier *fun = ID_FROM_PTR(p, ref);
struct inherit *inh;
if (IDENTIFIER_IS_ALIAS(fun->identifier_flags)) {
continue;
}
inh = INHERIT_FROM_INT(p, i);
switch(fun->identifier_flags & IDENTIFIER_TYPE_MASK) {
case IDENTIFIER_PIKE_FUNCTION:
if (fun->func.offset == -1) {
continue;
}
if (((size_t)fun->func.offset) >= inh->prog->num_program) {
Pike_fatal("Function %s offset (%ld) out of whack (max: %ld)!\n",
fun->name?fun->name->str:"<no-name>",
fun->func.const_info.offset,
(long)inh->prog->num_program);
}
break;
case IDENTIFIER_C_FUNCTION:
continue;
case IDENTIFIER_CONSTANT:
if (fun->func.const_info.offset < 0) {
continue;
}
if (fun->func.const_info.offset >= inh->prog->num_constants) {
Pike_fatal("Constant %s offset (%d) out of whack (max: %ld)!\n",
fun->name?fun->name->str:"<no-name>",
fun->func.const_info.offset,
(long)inh->prog->num_constants);
}
break;
case IDENTIFIER_VARIABLE:
switch(fun->run_time_type) {
case PIKE_T_GET_SET:
break;
case PIKE_T_FREE:
continue;
default:
{
ptrdiff_t offset = inh->storage_offset + fun->func.offset +
sizeof_variable(fun->run_time_type);
if (offset > p->storage_needed) {
Pike_fatal("Variable %s offset (%ld (%d)) out of whack (max: %ld)!\n",
fun->name?fun->name->str:"<no-name>",
(long)offset, fun->func.offset,
(long)p->storage_needed);
}
}
}
break;
}
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #endif
|
354bbe | 2007-09-24 | Henrik Grubbström (Grubba) | |
|
da371d | 2003-11-18 | Henrik Grubbström (Grubba) | | for (i=0; i < p->num_identifiers; i++) {
|
354bbe | 2007-09-24 | Henrik Grubbström (Grubba) | | if (IDENTIFIER_IS_FUNCTION(p->identifiers[i].identifier_flags) &&
(p->identifiers[i].run_time_type == T_MIXED)) {
|
0a7438 | 2009-06-21 | Henrik Grubbström (Grubba) | | * Consider this a fatal?
|
354bbe | 2007-09-24 | Henrik Grubbström (Grubba) | | */
p->identifiers[i].run_time_type = T_FUNCTION;
|
da371d | 2003-11-18 | Henrik Grubbström (Grubba) | | }
}
|
757128 | 2003-06-03 | Martin Stjernholm | |
for (i = 0; i < p->num_identifier_references; i++) {
struct reference *ref = p->identifier_references + i;
if (ref->id_flags & ID_HIDDEN) continue;
|
2c740d | 2013-05-26 | Henrik Grubbström (Grubba) | | if (ref->id_flags & ID_VARIANT) continue;
|
757128 | 2003-06-03 | Martin Stjernholm | | if (ref->inherit_offset != 0) continue;
|
aaf40c | 2013-11-03 | Henrik Grubbström (Grubba) | | override_identifier (ref, ID_FROM_PTR (p, ref)->name, 0);
|
757128 | 2003-06-03 | Martin Stjernholm | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | for(e=i=0;i<(int)p->num_identifier_references;i++)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
struct reference *funp;
struct identifier *fun;
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funp=p->identifier_references+i;
|
722134 | 2007-09-04 | Henrik Grubbström (Grubba) | | if(funp->id_flags & ID_HIDDEN) continue;
|
2c740d | 2013-05-26 | Henrik Grubbström (Grubba) | | if(funp->id_flags & ID_VARIANT) continue;
|
e18d90 | 2002-04-26 | Henrik Grubbström (Grubba) | | fun=ID_FROM_PTR(p, funp);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(funp->id_flags & ID_INHERITED)
{
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | int found_better=-1;
int funa_is_prototype;
|
2e1a6a | 2008-05-29 | Henrik Grubbström (Grubba) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(funp->id_flags & ID_PRIVATE) continue;
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funa_is_prototype = fun->func.offset == -1;
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | for(t=i+1;t<(int)p->num_identifier_references;t++)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
struct reference *funpb;
struct identifier *funb;
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funpb=p->identifier_references+t;
|
722134 | 2007-09-04 | Henrik Grubbström (Grubba) | | if (funpb->id_flags & ID_HIDDEN) continue;
|
2c740d | 2013-05-26 | Henrik Grubbström (Grubba) | | if (funpb->id_flags & ID_VARIANT) continue;
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funb=ID_FROM_PTR(p,funpb);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | |
if(fun->name==funb->name)
{
|
0a7438 | 2009-06-21 | Henrik Grubbström (Grubba) | | if (!(funpb->id_flags & ID_PROTECTED)) {
found_better=t;
}
|
d89fa1 | 2002-04-26 | Henrik Grubbström (Grubba) | |
|
722134 | 2007-09-04 | Henrik Grubbström (Grubba) | | *
* Yes -- It's needed in case of mixin.
|
d89fa1 | 2002-04-26 | Henrik Grubbström (Grubba) | | */
if(funa_is_prototype && (funb->func.offset != -1) &&
!(funp->id_flags & ID_INLINE))
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | if ((c->lex.pragmas & ID_STRICT_TYPES) &&
|
6f25b5 | 2007-10-12 | Henrik Grubbström (Grubba) | | (funp->id_flags & ID_USED)) {
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | |
|
ff8572 | 2021-03-22 | Henrik Grubbström (Grubba) | | if (!pike_types_le(funb->type, fun->type, 0, 0)) {
|
94d66b | 2008-05-24 | Henrik Grubbström (Grubba) | | yytype_report(REPORT_WARNING, NULL, 0, fun->type,
NULL, 0, funb->type,
0, "Type mismatch when overloading %S.",
fun->name);
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | }
}
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funp->inherit_offset = funpb->inherit_offset;
funp->identifier_offset = funpb->identifier_offset;
}
if(!funa_is_prototype && funb->func.offset == -1)
{
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | if ((c->lex.pragmas & ID_STRICT_TYPES) &&
|
6f25b5 | 2007-10-12 | Henrik Grubbström (Grubba) | | (funpb->id_flags & ID_USED)) {
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | |
|
ff8572 | 2021-03-22 | Henrik Grubbström (Grubba) | | if (!pike_types_le(fun->type, funb->type, 0, 0)) {
|
94d66b | 2008-05-24 | Henrik Grubbström (Grubba) | | yytype_report(REPORT_WARNING, NULL, 0, funb->type,
NULL, 0, fun->type,
0, "Type mismatch when overloading %S.",
fun->name);
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | }
}
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | funpb->inherit_offset = funp->inherit_offset;
funpb->identifier_offset = funp->identifier_offset;
}
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | if(found_better!=-1)
continue;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
a542da | 2008-01-24 | Martin Stjernholm | | if (IDENTIFIER_IS_PIKE_FUNCTION(fun->identifier_flags) &&
(fun->func.offset == -1) && (funp->id_flags & ID_INLINE)) {
|
2c448d | 2004-11-05 | Henrik Grubbström (Grubba) | | my_yyerror("Missing definition for local function %S.",
fun->name);
|
e18d90 | 2002-04-26 | Henrik Grubbström (Grubba) | | }
|
95489a | 2008-06-29 | Martin Nilsson | | if (funp->id_flags & ID_PROTECTED) continue;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | add_to_identifier_index(i);
}
|
ab9db5 | 2003-02-20 | Henrik Grubbström (Grubba) | | fsort_program_identifier_index(p->identifier_index,
p->identifier_index +
p->num_identifier_index - 1,
p);
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
2fb986 | 2008-09-04 | Henrik Grubbström (Grubba) | |
if (p->num_identifier_index) {
struct identifier *id = ID_FROM_INT(p, p->identifier_index[0]);
for (e = i = 1; e < p->num_identifier_index; e++) {
struct identifier *probe = ID_FROM_INT(p, p->identifier_index[e]);
if (probe == id) {
continue;
}
p->identifier_index[i++] = p->identifier_index[e];
id = probe;
}
p->num_identifier_index = i;
}
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
9a2009 | 2003-12-30 | Henrik Grubbström (Grubba) | | p->flags |= PROGRAM_FIXED;
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | {
int found = 1;
int n;
size_t num_lfuns = 1;
INT16 *lfuns;
for (n = i = 1; i < (int)NELEM(lfun_names); i++,n++) {
if (!lfun_names[i]) {
n |= 0xf;
found = 0;
continue;
}
if (found) {
num_lfuns++;
continue;
}
found = low_find_lfun(p, n) != -1;
if (found) {
num_lfuns += (n & 0xf) + 1;
}
}
lfuns = malloc(sizeof(INT16) * ((NUM_LFUNS >> 4) + num_lfuns + 1));
lfuns[0] = (NUM_LFUNS >> 4) + 1;
for (i = 1; i <= (NUM_LFUNS >> 4); i++) {
lfuns[i] = 0;
}
memset(lfuns + ((NUM_LFUNS >> 4) + 1), 0xff,
sizeof(INT16) * num_lfuns);
num_lfuns = (NUM_LFUNS>>4) + 1;
lfuns[num_lfuns] = p->lfuns[num_lfuns];
num_lfuns++;
free(p->lfuns);
p->lfuns = lfuns;
for (n = i = 1; i < (int)NELEM(lfun_names); i++,n++) {
if (!lfun_names[i]) {
n |= 0xf;
continue;
}
found = low_find_lfun(p, n);
if (found != -1) {
if (!lfuns[n>>4]) {
lfuns[n>>4] = num_lfuns;
num_lfuns += n & 0x0f;
}
lfuns[lfuns[n>>4] + (n & 0x0f)] = found;
}
if (lfuns[n>>4]) {
num_lfuns++;
}
}
}
|
ca9e40 | 2012-10-09 | Henrik Grubbström (Grubba) | |
for (i = 0; i < p->num_identifier_references; i++) {
struct reference *ref = p->identifier_references + i;
if (ref->id_flags & ID_HIDDEN) continue;
|
2c740d | 2013-05-26 | Henrik Grubbström (Grubba) | | if (ref->id_flags & ID_VARIANT) continue;
|
ca9e40 | 2012-10-09 | Henrik Grubbström (Grubba) | | if (ref->inherit_offset != 0) continue;
if ((ref->id_flags & (ID_HIDDEN|ID_PRIVATE|ID_USED)) == ID_PRIVATE) {
yywarning("%S is private but not used anywhere.",
ID_FROM_PTR(p, ref)->name);
}
|
2c1709 | 1999-06-22 | Fredrik Hübinette (Hubbe) | | }
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | |
99cce5 | 2007-05-26 | Martin Stjernholm | | * inherited PROGRAM_LIVE_OBJ flags. This is done at fixation time
* to allow the user to set and clear that flag while the program is
* being built. */
if (!(p->flags & PROGRAM_LIVE_OBJ)) {
|
3a5d0a | 2019-12-01 | Henrik Grubbström (Grubba) | | int e, destruct = QUICK_FIND_LFUN(p, LFUN__DESTRUCT);
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | | if (destruct > -1) {
struct identifier *id = ID_FROM_INT (p, destruct);
|
99cce5 | 2007-05-26 | Martin Stjernholm | | if (!IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags) ||
id->func.offset != -1) {
|
f76ace | 2017-11-05 | Henrik Grubbström (Grubba) | |
|
99cce5 | 2007-05-26 | Martin Stjernholm | | p->flags |= PROGRAM_LIVE_OBJ;
goto program_live_obj_set;
}
}
for (e = p->num_inherits - 1; e >= 0; e--)
if (p->inherits[e].prog->flags & PROGRAM_LIVE_OBJ) {
p->flags |= PROGRAM_LIVE_OBJ;
break;
}
program_live_obj_set:;
}
|
cd2be3 | 2004-03-13 | Henrik Grubbström (Grubba) | | if(Pike_compiler->flags & COMPILATION_CHECK_FINAL)
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | {
for(i=0;i<(int)p->num_identifier_references;i++)
{
|
ab0d47 | 2007-12-28 | Martin Nilsson | | if((p->identifier_references[i].id_flags & (ID_FINAL|ID_HIDDEN)) ==
ID_FINAL)
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | {
|
9fca41 | 2017-07-31 | Martin Nilsson | | struct pike_string *name=ID_FROM_INT(p, i)->name;
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | |
e=find_shared_string_identifier(name,p);
|
5a071a | 2001-10-02 | Fredrik Hübinette (Hubbe) | | if(e == -1)
|
e9900c | 2002-04-17 | Henrik Grubbström (Grubba) | | e=really_low_find_shared_string_identifier(name, p,
|
653093 | 2008-06-29 | Martin Nilsson | | SEE_PROTECTED|SEE_PRIVATE);
|
5a071a | 2001-10-02 | Fredrik Hübinette (Hubbe) | |
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | if((e != i) && (e != -1))
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | {
|
2c448d | 2004-11-05 | Henrik Grubbström (Grubba) | | my_yyerror("Illegal to redefine final identifier %S", name);
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | }
}
}
}
|
98bc6f | 2001-09-27 | Henrik Grubbström (Grubba) | |
|
475023 | 2019-03-08 | Henrik Grubbström (Grubba) | | if (p->num_annotations) {
struct pike_string *save_file = c->lex.current_file;
INT_TYPE save_line = c->lex.current_line;
for (i = 0; i < p->num_annotations; i++) {
struct multiset *l = p->annotations[i];
int d;
if (!l) continue;
c->lex.current_line = p->identifiers[i].linenumber;
c->lex.current_file = p->strings[p->identifiers[i].filename_strno];
for (d = 0; d < p->num_identifier_references; d++) {
struct reference *ref = p->identifier_references + d;
ptrdiff_t pos;
if (ref->inherit_offset || (ref->identifier_offset != i)) continue;
for (pos = multiset_first(l); pos >= 0; pos = multiset_next(l, pos)) {
push_multiset_index(l, pos);
if (TYPEOF(Pike_sp[-1]) == PIKE_T_OBJECT) {
struct object *o = Pike_sp[-1].u.object;
struct program *op = o->prog;
if (op) {
struct inherit *inh = op->inherits + SUBTYPEOF(Pike_sp[-1]);
int fun;
op = inh->prog;
fun = find_identifier("end_pass_identifier", op);
if (fun >= 0) {
fun += inh->identifier_level;
push_int(COMPILER_PASS_LAST);
ref_push_program(p);
push_int(d);
ref_push_object_inherit(Pike_fp->current_object,
Pike_fp->context -
Pike_fp->current_program->inherits);
safe_apply_low2(o, fun, 4, NULL);
pop_stack();
}
}
}
pop_stack();
}
sub_msnode_ref(l);
}
}
c->lex.current_file = save_file;
c->lex.current_line = save_line;
}
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | #ifdef DEBUG_MALLOC
{
#define DBSTR(X) ((X)?(X)->str:"")
int e,v;
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE line;
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | struct pike_string *tmp;
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | struct memory_map *m=0;;
|
13670c | 2015-05-25 | Martin Nilsson | | if(c->lex.current_file &&
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_file->str &&
c->lex.current_file->len &&
!strcmp(c->lex.current_file->str,"-"))
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | m=dmalloc_alloc_mmap( DBSTR(c->lex.current_file), c->lex.current_line);
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | else if( (tmp=find_program_name(Pike_compiler->new_program, &line)) )
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | {
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | m=dmalloc_alloc_mmap( tmp->str, line);
free_string(tmp);
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | }else{
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | m=dmalloc_alloc_mmap( "program id", Pike_compiler->new_program->id);
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | for(e=0;e<Pike_compiler->new_program->num_inherits;e++)
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | struct inherit *i=Pike_compiler->new_program->inherits+e;
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | char *tmp;
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | struct pike_string *tmp2 = NULL;
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | char buffer[50];
for(v=0;v<i->prog->num_variable_index;v++)
{
int d=i->prog->variable_index[v];
struct identifier *id=i->prog->identifiers+d;
dmalloc_add_mmap_entry(m,
id->name->str,
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | | i->storage_offset + id->func.offset,
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | sizeof_variable(id->run_time_type),
1,
0,0);
}
if(i->name)
{
tmp=i->name->str;
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | }
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | else if(!(tmp2 = find_program_name(i->prog, &line)))
|
a4033e | 2000-04-14 | Fredrik Hübinette (Hubbe) | | {
sprintf(buffer,"inherit[%d]",e);
tmp=buffer;
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | } else {
tmp = tmp2->str;
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | }
dmalloc_add_mmap_entry(m,
tmp,
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | | i->storage_offset,
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | i->prog->storage_needed - i->prog->inherits[0].storage_offset,
1,
0,0);
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | if (tmp2) {
free_string(tmp2);
}
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | dmalloc_set_mmap_template(Pike_compiler->new_program, m);
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | }
#endif
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | struct program *low_allocate_program(void)
{
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | struct program *p=alloc_program();
|
21b12a | 2014-09-03 | Martin Nilsson | | memset(p, 0, sizeof(struct program));
|
abe64b | 2018-05-19 | Tobias S. Josefowitz | | gc_init_marker(p);
|
aa68b1 | 2001-03-19 | Fredrik Hübinette (Hubbe) | | p->flags|=PROGRAM_VIRGIN;
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | p->alignment_needed=1;
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
7bf623 | 2000-04-23 | Martin Stjernholm | | GC_ALLOC(p);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | p->id=++current_program_id;
|
938632 | 2011-07-21 | Henrik Grubbström (Grubba) | | INIT_PIKE_MEMOBJ(p, T_PROGRAM);
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | DOUBLELINK(first_program, p);
|
f01020 | 2011-11-16 | Tobias S. Josefowitz | | ACCURATE_GETTIMEOFDAY(& p->timestamp);
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | |
p->lfuns = malloc(sizeof(INT16) * ((NUM_LFUNS >> 4) + 1 + 16));
memset(p->lfuns, 0x00, sizeof(INT16) * ((NUM_LFUNS >> 4) + 1));
memset(p->lfuns + (NUM_LFUNS >> 4) + 1, 0xff, sizeof(INT16) * 16);
p->lfuns[0] = (NUM_LFUNS >> 4) + 1;
|
c7565c | 2021-11-15 | Henrik Grubbström (Grubba) | |
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | return p;
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | * Start building a new program
*/
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | void low_start_new_program(struct program *p,
|
757128 | 2003-06-03 | Martin Stjernholm | | int pass,
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | struct pike_string *name,
int flags,
int *idp)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
757128 | 2003-06-03 | Martin Stjernholm | | int id=0;
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | struct svalue tmp;
|
5c8e89 | 1995-10-29 | Fredrik Hübinette (Hubbe) | |
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | CHECK_COMPILER();
|
8b5b3a | 2014-04-28 | Henrik Grubbström (Grubba) | | |
58544f | 1998-07-17 | Henrik Grubbström (Grubba) | | */
|
8b5b3a | 2014-04-28 | Henrik Grubbström (Grubba) | | lock_pike_compiler();
|
a91ca0 | 1998-07-10 | Henrik Grubbström (Grubba) | |
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth++;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | SET_SVAL_TYPE(tmp, T_PROGRAM);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!p)
{
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | p=low_allocate_program();
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | if(name)
{
tmp.u.program=p;
id=add_constant(name, &tmp, flags & ~ID_EXTERN);
|
51717a | 2001-04-09 | Fredrik Hübinette (Hubbe) | | #if 0
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | fprintf(stderr,"Compiling class %s, depth=%d\n",
name->str, c->compilation_depth);
|
51717a | 2001-04-09 | Fredrik Hübinette (Hubbe) | | }else{
fprintf(stderr,"Compiling file %s, depth=%d\n",
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_file ? c->lex.current_file->str : "-",
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth);
|
51717a | 2001-04-09 | Fredrik Hübinette (Hubbe) | | #endif
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }else{
|
d5f68a | 2018-11-14 | Henrik Grubbström (Grubba) | | int e;
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | tmp.u.program=p;
|
8c8337 | 1998-04-16 | Fredrik Hübinette (Hubbe) | | add_ref(p);
|
d38e6a | 2017-12-14 | Henrik Grubbström (Grubba) | | if((pass != COMPILER_PASS_FIRST) && name)
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | {
struct identifier *i;
id=isidentifier(name);
if (id < 0)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program constant disappeared in second pass.\n");
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | i=ID_FROM_INT(Pike_compiler->new_program, id);
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | free_type(i->type);
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | i->type=get_type_of_svalue(&tmp);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
d38e6a | 2017-12-14 | Henrik Grubbström (Grubba) | | if (pass == COMPILER_PASS_FIRST) {
|
315271 | 2008-08-17 | Martin Stjernholm | | if(c->compilation_depth >= 1) {
|
7d6575 | 2003-06-04 | Henrik Grubbström (Grubba) | | add_ref(p->parent = Pike_compiler->new_program);
|
315271 | 2008-08-17 | Martin Stjernholm | | debug_malloc_touch (p);
}
|
7d6575 | 2003-06-04 | Henrik Grubbström (Grubba) | | }
|
aa68b1 | 2001-03-19 | Fredrik Hübinette (Hubbe) | | p->flags &=~ PROGRAM_VIRGIN;
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | if(idp) *idp=id;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) %p low_start_new_program() %s "
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | "pass=%d: compilation_depth:%d\n",
|
a91d9a | 2016-01-11 | Martin Nilsson | | (long)th_self(), p, name ? name->str : "-",
Pike_compiler->compiler_pass,
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | c->compilation_depth);
|
cb6704 | 2001-12-12 | Martin Stjernholm | |
|
fb2f66 | 1998-11-05 | Fredrik Hübinette (Hubbe) | | init_type_stack();
|
5c8e89 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | #define PUSH
#include "compilation.h"
|
b8cda2 | 1997-01-21 | Fredrik Hübinette (Hubbe) | |
|
ddd996 | 2008-04-06 | Henrik Grubbström (Grubba) | | Pike_compiler->parent_identifier=id;
|
757128 | 2003-06-03 | Martin Stjernholm | | Pike_compiler->compiler_pass = pass;
|
1ecb5d | 2019-11-14 | Henrik Grubbström (Grubba) | | Pike_compiler->compiler = c;
|
e37a3e | 1999-10-09 | Fredrik Hübinette (Hubbe) | |
|
5b84a5 | 2008-04-26 | Henrik Grubbström (Grubba) | | Pike_compiler->num_used_modules=0;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
8f0612 | 2007-01-16 | Henrik Grubbström (Grubba) | | if(p->flags & PROGRAM_FINISHED)
|
0683be | 1997-01-26 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | yyerror("Pass2: Program already done");
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->malloc_size_program = ALLOC_STRUCT(program);
Pike_compiler->fake_object=alloc_object();
|
193795 | 2002-12-08 | Henrik Grubbström (Grubba) | |
|
379b68 | 2002-09-30 | Marcus Comstedt | | #ifdef PIKE_DEBUG
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | Pike_compiler->fake_object->storage=(char *)malloc(256 * sizeof(struct svalue));
if (Pike_compiler->fake_object->storage) {
|
21b12a | 2014-09-03 | Martin Nilsson | | memset(Pike_compiler->fake_object->storage,0x55,256*sizeof(struct svalue));
|
a16179 | 2010-04-10 | Martin Stjernholm | | PIKE_MEM_WO_RANGE (Pike_compiler->fake_object->storage,
256 * sizeof (struct svalue));
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | }
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | #else
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | Pike_compiler->fake_object->storage=(char *)malloc(sizeof(struct parent_info));
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | #endif
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | if (!Pike_compiler->fake_object->storage) {
yyerror("Out of memory when allocating object storage.");
}
|
ddac67 | 2000-07-02 | Martin Stjernholm | |
if (Pike_in_gc) remove_marker(Pike_compiler->fake_object);
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->fake_object->next=Pike_compiler->fake_object;
Pike_compiler->fake_object->prev=Pike_compiler->fake_object;
|
50ea68 | 2003-03-14 | Henrik Grubbström (Grubba) | | Pike_compiler->fake_object->refs=0;
add_ref(Pike_compiler->fake_object);
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->fake_object->prog=p;
|
3aa0db | 1999-10-22 | Henrik Grubbström (Grubba) | | add_ref(p);
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | |
#ifdef PIKE_DEBUG
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->fake_object->program_id=p->id;
|
1e4e5f | 2000-04-07 | Fredrik Hübinette (Hubbe) | | #endif
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_compiler->fake_object);
debug_malloc_touch(Pike_compiler->fake_object->storage);
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | |
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | if (Pike_compiler->fake_object->storage) {
if(name)
{
|
315271 | 2008-08-17 | Martin Stjernholm | |
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | if((((struct parent_info *)Pike_compiler->fake_object->storage)->parent=Pike_compiler->previous->fake_object))
add_ref(Pike_compiler->previous->fake_object);
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | ((struct parent_info *)Pike_compiler->fake_object->storage)->parent_identifier=id;
|
033d23 | 2007-01-16 | Henrik Grubbström (Grubba) | | }else{
((struct parent_info *)Pike_compiler->fake_object->storage)->parent=0;
((struct parent_info *)Pike_compiler->fake_object->storage)->parent_identifier=0;
}
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program=p;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
a78643 | 1999-11-18 | Martin Stjernholm | | #ifdef PROGRAM_BUILD_DEBUG
if (name) {
|
8411e5 | 2017-01-28 | Henrik Grubbström (Grubba) | | fprintf (stderr, "%*sstarting program %d (pass=%d): ",
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth, "",
Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
|
a78643 | 1999-11-18 | Martin Stjernholm | | push_string (name);
|
cd8632 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | print_svalue (stderr, --Pike_sp);
|
a78643 | 1999-11-18 | Martin Stjernholm | | putc ('\n', stderr);
}
else
|
8411e5 | 2017-01-28 | Henrik Grubbström (Grubba) | | fprintf (stderr, "%*sstarting program %d (pass=%d)\n",
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth, "",
Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
|
a78643 | 1999-11-18 | Martin Stjernholm | | #endif
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | if (c->compilation_depth >= 1) {
|
ec8008 | 2014-08-24 | Martin Nilsson | | if(c->lex.pragmas & ID_SAVE_PARENT)
|
2fbfc4 | 2002-06-11 | Martin Stjernholm | | {
|
f39720 | 2002-06-12 | Martin Stjernholm | | p->flags |= PROGRAM_USES_PARENT;
|
ec8008 | 2014-08-24 | Martin Nilsson | | } else if (!(c->lex.pragmas & ID_DONT_SAVE_PARENT)) {
|
f39720 | 2002-06-12 | Martin Stjernholm | | struct pike_string *tmp=findstring("__pragma_save_parent__");
if(tmp)
|
2fbfc4 | 2002-06-11 | Martin Stjernholm | | {
|
f39720 | 2002-06-12 | Martin Stjernholm | | struct node_s *n=find_module_identifier(tmp, 0);
if(n)
{
int do_save_parent = !node_is_false(n);
free_node(n);
if (do_save_parent) p->flags |= PROGRAM_USES_PARENT;
}
|
2fbfc4 | 2002-06-11 | Martin Stjernholm | | }
}
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_compiler->fake_object);
debug_malloc_touch(Pike_compiler->fake_object->storage);
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->new_program->program)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
Pike_compiler->malloc_size_program->PIKE_CONCAT(num_,NAME) = \
Pike_compiler->new_program->PIKE_CONCAT(num_,NAME);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | |
{
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE line = 0;
INT32 off = 0;
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | size_t len = 0;
INT32 shift = 0;
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | struct pike_string *file=0;
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | char *cnt=Pike_compiler->new_program->linenumbers;
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | while(cnt < Pike_compiler->new_program->linenumbers +
Pike_compiler->new_program->num_linenumbers)
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | | {
if(*cnt == 127)
{
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | int strno;
|
50edc8 | 2001-07-13 | Henrik Grubbström (Grubba) | | cnt++;
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | strno = get_small_number(&cnt);
CHECK_FILE_ENTRY (Pike_compiler->new_program, strno);
file = Pike_compiler->new_program->strings[strno];
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | | }
off+=get_small_number(&cnt);
line+=get_small_number(&cnt);
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->last_line=line;
Pike_compiler->last_pc=off;
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | | if(file)
{
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->last_file) free_string(Pike_compiler->last_file);
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | copy_shared_string(Pike_compiler->last_file, file);
|
101602 | 1999-10-28 | Fredrik Hübinette (Hubbe) | | }
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }else{
static struct pike_string *s;
struct inherit i;
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | if (Pike_compiler->new_program->strings) {
struct pike_string **str = Pike_compiler->new_program->strings;
int j = Pike_compiler->new_program->num_strings;
while(j--) {
free_string(*str);
str++;
}
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #define START_SIZE 64
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #ifdef PIKE_USE_MACHINE_CODE
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \
if (Pike_compiler->new_program->NAME) { \
mexec_free(Pike_compiler->new_program->NAME); \
Pike_compiler->new_program->PIKE_CONCAT(num_,NAME) = 0; \
} \
Pike_compiler->malloc_size_program->PIKE_CONCAT(num_,NAME) = \
START_SIZE; \
Pike_compiler->new_program->NAME = \
(TYPE *)mexec_alloc(sizeof(TYPE) * START_SIZE);
|
13670c | 2015-05-25 | Martin Nilsson | | #endif /* PIKE_USE_MACHINE_CODE */
|
7e877a | 2003-04-02 | Martin Stjernholm | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
7c7a3f | 2002-12-01 | Martin Stjernholm | | if (Pike_compiler->new_program->NAME) { \
free (Pike_compiler->new_program->NAME); \
Pike_compiler->new_program->PIKE_CONCAT(num_,NAME) = 0; \
} \
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | Pike_compiler->malloc_size_program->PIKE_CONCAT(num_,NAME) = \
START_SIZE; \
Pike_compiler->new_program->NAME = \
(TYPE *)xalloc(sizeof(TYPE) * START_SIZE);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | i.prog=Pike_compiler->new_program;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | i.identifier_level=0;
i.storage_offset=0;
i.inherit_level=0;
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | i.identifier_ref_offset=0;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | i.parent=0;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | i.parent_identifier=-1;
|
684bd2 | 2003-08-02 | Martin Stjernholm | | i.parent_offset=OBJECT_PARENT;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | i.name=0;
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | i.annotations = NULL;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | add_to_inherits(i);
|
0683be | 1997-01-26 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->init_node=0;
Pike_compiler->num_parse_error=0;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | push_compiler_frame(0);
|
be6fec | 2001-04-01 | Henrik Grubbström (Grubba) | | copy_pike_type(Pike_compiler->compiler_frame->current_return_type,
void_type_string);
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_compiler->fake_object);
debug_malloc_touch(Pike_compiler->fake_object->storage);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | PMOD_EXPORT void debug_start_new_program(INT_TYPE line, const char *file)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct pike_string *save_file;
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE save_line;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c;
CHECK_COMPILER();
c = THIS_COMPILATION;
save_file = dmalloc_touch(struct pike_string *, c->lex.current_file);
save_line = c->lex.current_line;
|
cbb2be | 2003-02-04 | Martin Stjernholm | |
{
const char *p = DEFINETOSTR(PIKE_SRC_ROOT), *f = file;
while (*p && *p == *f) p++, f++;
while (*f == '/' || *f == '\\') f++;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_file = make_shared_string(f);
c->lex.current_line = line;
|
cbb2be | 2003-02-04 | Martin Stjernholm | | }
|
2fbfc4 | 2002-06-11 | Martin Stjernholm | |
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) start_new_program(%ld, %s): "
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | "compilation_depth:%d\n",
|
a91d9a | 2016-01-11 | Martin Nilsson | | (long)th_self(), (long)line, file,
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | c->compilation_depth);
|
b6f8c3 | 1999-07-01 | Henrik Grubbström (Grubba) | |
|
d38e6a | 2017-12-14 | Henrik Grubbström (Grubba) | | low_start_new_program(0, COMPILER_PASS_FIRST, 0, 0, 0);
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | store_linenumber(line,c->lex.current_file);
|
2fbfc4 | 2002-06-11 | Martin Stjernholm | | debug_malloc_name(Pike_compiler->new_program, file, line);
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | free_string(c->lex.current_file);
c->lex.current_file = dmalloc_touch(struct pike_string *, save_file);
c->lex.current_line = save_line;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | static void exit_program_struct(struct program *p)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
7e877a | 2003-04-02 | Martin Stjernholm | | unsigned e;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
d631b8 | 2002-12-01 | Martin Stjernholm | | #ifdef PIKE_DEBUG
if (p->refs) {
#ifdef DEBUG_MALLOC
|
4fab5f | 2004-04-18 | Martin Stjernholm | | fprintf (stderr, "Program to be freed still got %d references:\n", p->refs);
|
d631b8 | 2002-12-01 | Martin Stjernholm | | describe_something(p, T_PROGRAM, 0,2,0, NULL);
#endif
Pike_fatal("Program to be freed still got %d references.\n", p->refs);
}
#endif
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | if(p->parent)
{
|
c82a99 | 2001-04-13 | Henrik Grubbström (Grubba) | |
struct program *parent = p->parent;
p->parent = NULL;
|
8444d3 | 2008-01-28 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
|
46b876 | 2008-01-28 | Henrik Grubbström (Grubba) | | if (!parent->refs) {
dump_program_tables(p, 2);
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | fprintf(stderr, "Dead parent:\n");
dump_program_tables(parent, 2);
|
46b876 | 2008-01-28 | Henrik Grubbström (Grubba) | | Pike_fatal("Program parent is dead.\n");
}
|
8444d3 | 2008-01-28 | Henrik Grubbström (Grubba) | | #endif
|
c82a99 | 2001-04-13 | Henrik Grubbström (Grubba) | | free_program(parent);
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | | }
|
29d1e6 | 2005-05-31 | Henrik Grubbström (Grubba) | |
|
1c1c5e | 2001-04-08 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(id_to_program_cache[p->id & (ID_TO_PROGRAM_CACHE_SIZE-1)]==p)
id_to_program_cache[p->id & (ID_TO_PROGRAM_CACHE_SIZE-1)]=0;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(p->strings)
for(e=0; e<p->num_strings; e++)
if(p->strings[e])
free_string(p->strings[e]);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | if (p->annotations) {
for (e = 0; e < p->num_annotations; e++) {
|
b2dc95 | 2018-12-17 | Henrik Grubbström (Grubba) | | do_free_multiset(p->annotations[e]);
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | }
}
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(p->identifiers)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | for(e=0; e<p->num_identifiers; e++)
{
if(p->identifiers[e].name)
free_string(p->identifiers[e].name);
if(p->identifiers[e].type)
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | free_type(p->identifiers[e].type);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(p->constants)
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | {
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | for(e=0;e<p->num_constants;e++)
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | {
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | free_svalue(& p->constants[e].sval);
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | #if 0
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | if(p->constants[e].name) free_string(p->constants[e].name);
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | #endif /* 0 */
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | }
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(p->inherits)
for(e=0; e<p->num_inherits; e++)
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | {
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | if (p->inherits[e].annotations)
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | | free_multiset(p->inherits[e].annotations);
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(p->inherits[e].name)
free_string(p->inherits[e].name);
if(e)
{
if(p->inherits[e].prog)
free_program(p->inherits[e].prog);
}
if(p->inherits[e].parent)
free_object(p->inherits[e].parent);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | DOUBLEUNLINK(first_program, p);
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(p->flags & PROGRAM_OPTIMIZED)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
9173f7 | 2002-11-25 | Martin Stjernholm | | #ifdef PIKE_USE_MACHINE_CODE
|
e43a14 | 2005-06-09 | Henrik Grubbström (Grubba) | | do {
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \
if (p->NAME) mexec_free(p->NAME);
#define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
if (p->NAME) { \
dmfree(p->NAME); \
break; \
}
#include "program_areas.h"
} while(0);
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #else /* PIKE_USE_MACHINE_CODE */
|
e43a14 | 2005-06-09 | Henrik Grubbström (Grubba) | | if(p->program) {
|
424d9c | 1999-05-02 | Fredrik Hübinette (Hubbe) | | dmfree(p->program);
|
9173f7 | 2002-11-25 | Martin Stjernholm | | }
|
e43a14 | 2005-06-09 | Henrik Grubbström (Grubba) | | #endif /* PIKE_USE_MACHINE_CODE */
|
31906a | 2008-04-19 | Henrik Grubbström (Grubba) | | #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) do { \
p->NAME=0; \
} while(0);
|
13670c | 2015-05-25 | Martin Nilsson | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }else{
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #ifdef PIKE_USE_MACHINE_CODE
#define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
31906a | 2008-04-19 | Henrik Grubbström (Grubba) | | if(p->NAME) { \
mexec_free((char *)p->NAME); p->NAME=0; \
}
|
d71735 | 2005-05-25 | Henrik Grubbström (Grubba) | | #endif /* PIKE_USE_MACHINE_CODE */
#define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
|
31906a | 2008-04-19 | Henrik Grubbström (Grubba) | | if(p->NAME) { \
dmfree((char *)p->NAME); p->NAME=0; \
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #include "program_areas.h"
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | if (p->lfuns) {
free(p->lfuns);
}
|
45637c | 2001-04-07 | Fredrik Hübinette (Hubbe) | | EXIT_PIKE_MEMOBJ(p);
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
553d23 | 2000-09-14 | Martin Stjernholm | | GC_FREE(p);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | void dump_program_desc(struct program *p)
{
int e,d,q;
|
a1f852 | 2002-06-11 | Martin Stjernholm | | fprintf(stderr,"$$$$$ dump_program_desc for %p\n", p);
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | fprintf(stderr,"All inherits:\n");
for(e=0;e<p->num_inherits;e++)
{
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | fprintf(stderr,"%3d:\n",e);
|
b8896b | 2000-02-10 | Fredrik Hübinette (Hubbe) | | for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"inherited program: %d\n",p->inherits[e].prog->id);
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | if(p->inherits[e].name)
{
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"name : %s\n",p->inherits[e].name->str);
}
|
e164be | 2018-12-23 | Henrik Grubbström (Grubba) | | if (p->inherits[e].annotations) {
union msnode *node = low_multiset_first(p->inherits[e].annotations->msd);
fprintf(stderr, "annotations:\n");
while (node) {
if (TYPEOF(node->i.ind) != T_DELETED) {
low_push_multiset_index(node);
safe_pike_fprintf(stderr, " %O\n", Pike_sp-1);
pop_stack();
}
node = low_multiset_next(node);
}
}
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | | for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"inherit_level: %d\n",p->inherits[e].inherit_level);
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"identifier_level: %d\n",p->inherits[e].identifier_level);
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"parent_identifier: %d\n",p->inherits[e].parent_identifier);
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"parent_offset: %d\n",p->inherits[e].parent_offset);
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
|
63540d | 2000-08-15 | Henrik Grubbström (Grubba) | | fprintf(stderr,"storage_offset: %ld\n",
|
bd6739 | 2015-10-14 | Martin Nilsson | | (long)p->inherits[e].storage_offset);
|
5f05c1 | 1999-12-27 | Fredrik Hübinette (Hubbe) | |
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"parent: %p\n",p->inherits[e].parent);
if(p->inherits[e].parent &&
p->inherits[e].parent->prog &&
p->inherits[e].parent->prog->num_linenumbers>1)
{
for(d=0;d<p->inherits[e].inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"parent: %s\n",p->inherits[e].parent->prog->linenumbers+1);
}
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | }
|
a1f852 | 2002-06-11 | Martin Stjernholm | | fprintf(stderr,"All identifier references:\n");
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | for(e=0;e<(int)p->num_identifier_references;e++)
{
|
a1f852 | 2002-06-11 | Martin Stjernholm | | struct inherit *inh = INHERIT_FROM_INT(p,e);
fprintf(stderr,"%3d: ",e);
for(d=0;d<inh->inherit_level;d++) fprintf(stderr," ");
fprintf(stderr,"%-40s flags 0x%x",ID_FROM_INT(p,e)->name->str,
p->identifier_references[e].id_flags);
for (q = 0; q < p->num_inherits; q++)
if (p->inherits + q == inh) {
|
722134 | 2007-09-04 | Henrik Grubbström (Grubba) | | fprintf(stderr,
" inherit %d\n"
" type: ",
q);
simple_describe_type(ID_FROM_INT(p, e)->type);
fprintf(stderr, "\n");
|
a1f852 | 2002-06-11 | Martin Stjernholm | | goto inherit_found;
}
fprintf (stderr, " inherit not found!\n");
inherit_found:;
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | }
fprintf(stderr,"All sorted identifiers:\n");
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | for(q=0;q<(int)p->num_identifier_index;q++)
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | {
e=p->identifier_index[q];
fprintf(stderr,"%3d (%3d):",e,q);
for(d=0;d<INHERIT_FROM_INT(p,e)->inherit_level;d++) fprintf(stderr," ");
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | fprintf(stderr,"%s;\n", ID_FROM_INT(p,e)->name->str);
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | }
|
a1f852 | 2002-06-11 | Martin Stjernholm | |
|
e164be | 2018-12-23 | Henrik Grubbström (Grubba) | | if (p->annotations) {
fprintf(stderr, "All identifier annotations:\n");
for (q = 0; q < p->num_annotations; q++) {
struct multiset *l = p->annotations[q];
union msnode *node;
if (!l) continue;
fprintf(stderr, " Identifier #%d: %s\n",
q, p->identifiers[q].name->str);
for (node = low_multiset_first(l->msd);
node;
node = low_multiset_next(node)) {
low_push_multiset_index(node);
safe_pike_fprintf(stderr, " %O\n", Pike_sp-1);
pop_stack();
}
}
}
|
a1f852 | 2002-06-11 | Martin Stjernholm | | fprintf(stderr,"$$$$$ dump_program_desc for %p done\n", p);
|
2acdd3 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | }
#endif
|
be478c | 1997-08-30 | Henrik Grubbström (Grubba) | | static void toss_compilation_resources(void)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->fake_object)
|
a3c6ad | 1998-01-29 | Fredrik Hübinette (Hubbe) | | {
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | if( ((struct parent_info *)Pike_compiler->fake_object->storage)->parent )
{
free_object(((struct parent_info *)Pike_compiler->fake_object->storage)->parent);
((struct parent_info *)Pike_compiler->fake_object->storage)->parent=0;
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_program(Pike_compiler->fake_object->prog);
Pike_compiler->fake_object->prog=0;
free_object(Pike_compiler->fake_object);
Pike_compiler->fake_object=0;
|
a3c6ad | 1998-01-29 | Fredrik Hübinette (Hubbe) | | }
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_program(Pike_compiler->new_program);
Pike_compiler->new_program=0;
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->malloc_size_program)
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | dmfree((char *)Pike_compiler->malloc_size_program);
Pike_compiler->malloc_size_program=0;
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->module_index_cache)
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_mapping(Pike_compiler->module_index_cache);
Pike_compiler->module_index_cache=0;
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | | }
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | while(Pike_compiler->compiler_frame)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_compiler_frame();
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | |
|
de1d7d | 2000-07-10 | Henrik Grubbström (Grubba) | | if(Pike_compiler->last_identifier)
{
free_string(Pike_compiler->last_identifier);
Pike_compiler->last_identifier=0;
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->last_file)
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | free_string(Pike_compiler->last_file);
Pike_compiler->last_file=0;
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | if (Pike_compiler->current_annotations) {
free_node(Pike_compiler->current_annotations);
Pike_compiler->current_annotations = NULL;
}
|
a2af98 | 2014-03-01 | Henrik Grubbström (Grubba) | | if (Pike_compiler->current_attributes) {
free_node(Pike_compiler->current_attributes);
Pike_compiler->current_attributes = NULL;
}
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | unuse_modules(Pike_compiler->num_used_modules);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
e964ae | 1998-04-08 | Fredrik Hübinette (Hubbe) | | int sizeof_variable(int run_time_type)
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | {
switch(run_time_type)
{
case T_FUNCTION:
case T_MIXED: return sizeof(struct svalue);
case T_FLOAT: return sizeof(FLOAT_TYPE);
|
2ba919 | 1999-10-23 | Fredrik Hübinette (Hubbe) | | case T_INT: return sizeof(INT_TYPE);
|
2e1a6a | 2008-05-29 | Henrik Grubbström (Grubba) | | case PIKE_T_FREE:
|
0fc3b9 | 2008-02-19 | Henrik Grubbström (Grubba) | | case PIKE_T_GET_SET: return 0;
|
6ccad4 | 2002-04-25 | Henrik Grubbström (Grubba) | | default: return sizeof(void *);
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | }
}
|
d3b06f | 2000-08-10 | Henrik Grubbström (Grubba) | | static ptrdiff_t alignof_variable(int run_time_type)
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | {
switch(run_time_type)
{
case T_FUNCTION:
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | case T_MIXED: return ALIGNOF(struct svalue);
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | case T_FLOAT: return ALIGNOF(FLOAT_TYPE);
|
2ba919 | 1999-10-23 | Fredrik Hübinette (Hubbe) | | case T_INT: return ALIGNOF(INT_TYPE);
|
2e1a6a | 2008-05-29 | Henrik Grubbström (Grubba) | | case PIKE_T_FREE:
|
0fc3b9 | 2008-02-19 | Henrik Grubbström (Grubba) | | case PIKE_T_GET_SET: return 1;
|
6ccad4 | 2002-04-25 | Henrik Grubbström (Grubba) | | default: return ALIGNOF(void *);
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | }
}
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
aa0422 | 2013-02-25 | Arne Goedeke | | PMOD_EXPORT void dump_program_tables (const struct program *p, int indent)
|
5ec106 | 2002-05-09 | Martin Stjernholm | | {
int d;
|
7d6575 | 2003-06-04 | Henrik Grubbström (Grubba) | | if (!p) {
fprintf(stderr, "%*sProgram: NULL\n\n", indent, "");
return;
}
|
5ec106 | 2002-05-09 | Martin Stjernholm | | fprintf(stderr,
"%*sProgram flags: 0x%04x\n\n",
indent, "", p->flags);
fprintf(stderr,
"%*sReference table:\n"
"%*s ####: Flags Inherit Identifier\n",
indent, "", indent, "");
for (d=0; d < p->num_identifier_references; d++) {
struct reference *ref = p->identifier_references + d;
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | struct identifier *id = ID_FROM_PTR(p, ref);
|
e5b745 | 2013-11-03 | Henrik Grubbström (Grubba) | | struct program *inh_p = INHERIT_FROM_PTR(p, ref)->prog;
|
5ec106 | 2002-05-09 | Martin Stjernholm | |
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | fprintf(stderr,
"%*s %4d: %5x %7d %10d %s\n"
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | "%*s %s:%ld\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "",
d, ref->id_flags, ref->inherit_offset,
ref->identifier_offset,
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | id->name->size_shift ? "(wide)" : id->name->str,
indent, "",
|
e5b745 | 2013-11-03 | Henrik Grubbström (Grubba) | | inh_p->num_strings?inh_p->strings[id->filename_strno]->str:"-",
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | (long)id->linenumber);
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {
fprintf (stderr, "%*s Alias for %d:%d\n",
indent, "", id->func.ext_ref.depth, id->func.ext_ref.id);
} else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {
fprintf (stderr, "%*s Constant #%ld\n",
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | indent, "", (long)id->func.const_info.offset);
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | } else if (IDENTIFIER_IS_VARIABLE(id->identifier_flags)) {
fprintf (stderr, "%*s Offset: 0x%08lx\n",
indent, "", (long)id->func.offset);
} else if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags)) {
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE line;
|
89a2ad | 2002-05-09 | Martin Stjernholm | | struct pike_string *file =
get_line (ID_FROM_PTR(p,ref)->func.offset + inh_p->program, inh_p, &line);
if (!file->size_shift)
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | fprintf (stderr, "%*s %s:%ld\n",
indent, "", file->str, (long)line);
|
fcbde0 | 2003-08-20 | Martin Stjernholm | | free_string (file);
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | } else {
fprintf (stderr, "%*s Cfun: %p\n",
indent, "", id->func.c_fun);
|
5ec106 | 2002-05-09 | Martin Stjernholm | | }
}
|
757128 | 2003-06-03 | Martin Stjernholm | |
fprintf(stderr, "\n"
"%*sIdentifier index table:\n"
|
2fb986 | 2008-09-04 | Henrik Grubbström (Grubba) | | "%*s ####: Index\tName\n",
|
757128 | 2003-06-03 | Martin Stjernholm | | indent, "", indent, "");
for (d = 0; d < p->num_identifier_index; d++) {
|
2fb986 | 2008-09-04 | Henrik Grubbström (Grubba) | | struct identifier *id = ID_FROM_INT(p, p->identifier_index[d]);
fprintf(stderr, "%*s %4d: %5d\t%s\n",
|
757128 | 2003-06-03 | Martin Stjernholm | | indent, "",
|
2fb986 | 2008-09-04 | Henrik Grubbström (Grubba) | | d, p->identifier_index[d],
id->name->size_shift ? "(wide)" : id->name->str);
|
757128 | 2003-06-03 | Martin Stjernholm | | }
|
5ec106 | 2002-05-09 | Martin Stjernholm | | fprintf(stderr, "\n"
"%*sInherit table:\n"
|
684bd2 | 2003-08-02 | Martin Stjernholm | | "%*s ####: Level prog_id id_level storage_offs "
"par_id par_offs par_obj_id id_ref_offs\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "", indent, "");
for (d=0; d < p->num_inherits; d++) {
struct inherit *inh = p->inherits + d;
|
2d76f2 | 2005-05-20 | Martin Stjernholm | | fprintf(stderr, "%*s %4d: %5d %7d %8d %12"PRINTPTRDIFFT"d %6d %8d %10d %11"PRINTSIZET"d\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "",
|
684bd2 | 2003-08-02 | Martin Stjernholm | | d, inh->inherit_level,
inh->prog ? inh->prog->id : -1,
inh->identifier_level, inh->storage_offset,
inh->parent_identifier, inh->parent_offset,
inh->parent ? inh->parent->program_id : -1,
inh->identifier_ref_offset);
|
e164be | 2018-12-23 | Henrik Grubbström (Grubba) | |
if (inh->annotations) {
union msnode *node = low_multiset_first(inh->annotations->msd);
int i;
for (i = 0; node; (node = low_multiset_next(node)), i++) {
fprintf(stderr, "%*s annotation #%d: ", indent, "", i);
low_push_multiset_index(node);
safe_pike_fprintf(stderr, "%O\n", Pike_sp-1);
pop_stack();
}
}
|
5ec106 | 2002-05-09 | Martin Stjernholm | | }
fprintf(stderr, "\n"
"%*sIdentifier table:\n"
"%*s ####: Flags Offset Type Name\n",
indent, "", indent, "");
for (d=0; d < p->num_identifiers; d++) {
struct identifier *id = p->identifiers + d;
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | fprintf(stderr,
|
ddcc6d | 2008-05-22 | Martin Stjernholm | | "%*s %4d: %5x %6"PRINTPTRDIFFT"d %4d \"%s\"\n"
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | "%*s %s:%ld\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "",
d, id->identifier_flags, id->func.offset,
|
0ed912 | 2008-05-16 | Henrik Grubbström (Grubba) | | id->run_time_type, id->name->str,
indent, "",
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | p->num_strings?p->strings[id->filename_strno]->str:"-",
(long)id->linenumber);
|
e164be | 2018-12-23 | Henrik Grubbström (Grubba) | | if ((d < p->num_annotations) && p->annotations[d]) {
union msnode *node = low_multiset_first(p->annotations[d]->msd);
int i;
for (i = 0; node; (node = low_multiset_next(node)), i++) {
fprintf(stderr, "%*s annotation #%d: ", indent, "", i);
low_push_multiset_index(node);
safe_pike_fprintf(stderr, "%O\n", Pike_sp-1);
pop_stack();
}
}
|
5ec106 | 2002-05-09 | Martin Stjernholm | | }
|
757128 | 2003-06-03 | Martin Stjernholm | |
|
5ec106 | 2002-05-09 | Martin Stjernholm | | fprintf(stderr, "\n"
"%*sVariable table:\n"
"%*s ####: Index\n",
indent, "", indent, "");
for (d = 0; d < p->num_variable_index; d++) {
fprintf(stderr, "%*s %4d: %5d\n",
indent, "",
d, p->variable_index[d]);
}
fprintf(stderr, "\n"
"%*sConstant table:\n"
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | "%*s ####: Type Raw\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "", indent, "");
for (d = 0; d < p->num_constants; d++) {
struct program_constant *c = p->constants + d;
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | #if 1
fprintf(stderr, "%*s %4d: %-15s %p\n",
|
5ec106 | 2002-05-09 | Martin Stjernholm | | indent, "",
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | d, get_name_of_type (TYPEOF(c->sval)),
|
cac624 | 2008-02-12 | Henrik Grubbström (Grubba) | | c->sval.u.ptr);
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | #else /* !0 */
|
2d76f2 | 2005-05-20 | Martin Stjernholm | | fprintf(stderr, "%*s %4d: %-15s %"PRINTPTRDIFFT"d\n",
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | indent, "",
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | d, get_name_of_type (TYPEOF(c->sval)),
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | c->offset);
#endif /* 0 */
|
5ec106 | 2002-05-09 | Martin Stjernholm | | }
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | |
|
17799f | 2008-04-24 | Henrik Grubbström (Grubba) | | fprintf(stderr, "\n"
"%*sString table:\n"
"%*s ####: Value\n",
indent, "", indent, "");
for (d = 0; d < p->num_strings; d++) {
|
194f07 | 2008-05-01 | Martin Stjernholm | | fprintf(stderr, "%*s %4d: [%p]\"%s\"(%"PRINTPTRDIFFT"d characters)\n",
|
17799f | 2008-04-24 | Henrik Grubbström (Grubba) | | indent, "", (int)d, p->strings[d], p->strings[d]->str, p->strings[d]->len);
}
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | fprintf(stderr, "\n"
"%*sLFUN table:\n"
"%*s LFUN Ref# Name\n",
indent, "", indent, "");
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | {
int n = 0;
for (d = 0; d < (int)NELEM(lfun_names); d++,n++) {
if (!lfun_names[d]) {
n |= 0xf;
continue;
}
if (QUICK_FIND_LFUN(p, n) != -1) {
fprintf(stderr, "%*s 0x%02x: %04d %s\n",
|
4c583f | 2021-02-09 | Henrik Grubbström (Grubba) | | indent, "", n, QUICK_FIND_LFUN(p, n),
lfun_names[d][0]?lfun_names[d]:(lfun_names[d]+1));
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | | }
}
}
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | |
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | | fprintf(stderr, "\n"
"%*sLinenumber table:\n",
indent, "");
{
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT32 off = 0;
INT_TYPE line = 0;
|
ad6a88 | 2002-11-07 | Henrik Grubbström (Grubba) | | char *cnt = p->linenumbers;
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | |
|
ad6a88 | 2002-11-07 | Henrik Grubbström (Grubba) | | while (cnt < p->linenumbers + p->num_linenumbers) {
|
f448e3 | 2019-03-21 | Henrik Grubbström (Grubba) | | while (*cnt == 127) {
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | int strno;
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | | cnt++;
|
547e58 | 2013-09-08 | Henrik Grubbström (Grubba) | | strno = get_small_number(&cnt);
|
f448e3 | 2019-03-21 | Henrik Grubbström (Grubba) | | if (strno >= 0) {
fprintf(stderr, "%*s Filename: String #%d\n", indent, "", strno);
} else {
int offset = ~strno;
int kind = *(cnt++);
strno = (kind >= 0)?get_small_number(&cnt):0;
switch(kind) {
case -1:
fprintf(stderr, "%*s Variable #%d end\n", indent, "", offset);
break;
case 0:
fprintf(stderr, "%*s Variable #%d name: string #%d\n",
indent, "", offset, strno);
break;
case 1:
fprintf(stderr, "%*s Variable #%d type: constant #%d\n",
indent, "", offset, strno);
break;
default:
fprintf(stderr, "%*s Variable #%d unknown (%d): value: %d\n",
indent, "", offset, kind, strno);
break;
}
}
if (cnt >= p->linenumbers + p->num_linenumbers) break;
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | | }
|
f448e3 | 2019-03-21 | Henrik Grubbström (Grubba) | | if (cnt >= p->linenumbers + p->num_linenumbers) break;
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | | off += get_small_number(&cnt);
line += get_small_number(&cnt);
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | fprintf(stderr, "%*s %8d:%8ld\n", indent, "", off, (long)line);
|
9b7828 | 2002-11-07 | Henrik Grubbström (Grubba) | | }
}
|
757128 | 2003-06-03 | Martin Stjernholm | |
|
5ec106 | 2002-05-09 | Martin Stjernholm | | fprintf(stderr, "\n");
}
|
624d09 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | void check_program(struct program *p)
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | {
|
6ce732 | 2008-07-16 | Martin Stjernholm | | unsigned INT32 e;
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | int variable_positions[1024];
|
8ba59a | 2000-03-26 | Fredrik Hübinette (Hubbe) | | if(p->flags & PROGRAM_AVOID_CHECK) return;
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | for(e=0;e<NELEM(variable_positions);e++)
variable_positions[e]=-1;
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
|
636e47 | 1998-04-15 | Fredrik Hübinette (Hubbe) | | if(p->id > current_program_id)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program id is out of sync! (p->id=%d, current_program_id=%d)\n",p->id,current_program_id);
|
636e47 | 1998-04-15 | Fredrik Hübinette (Hubbe) | |
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | if(p->refs <=0)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program has zero refs.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
if(p->next && p->next->prev != p)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program ->next->prev != program.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
if(p->prev)
{
if(p->prev->next != p)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program ->prev->next != program.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | }else{
if(first_program != p)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program ->prev == 0 but first_program != program.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | if(p->id > current_program_id || p->id <= 0)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program id is wrong.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
if(p->storage_needed < 0)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program->storage_needed < 0.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(p->num_identifier_index > p->num_identifier_references)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Too many identifier index entries in program!\n");
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_constants;e++)
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | {
|
aa771b | 2003-08-20 | Martin Stjernholm | | struct svalue *s = & p->constants[e].sval;
check_svalue(s);
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if (p->flags & PROGRAM_FINISHED && TYPEOF(*s) == T_OBJECT &&
|
aa771b | 2003-08-20 | Martin Stjernholm | | s->u.object->next == s->u.object)
Pike_fatal ("Got fake object in constant in finished program.\n");
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | #if 0
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | if(p->constants[e].name) check_string(p->constants[e].name);
|
4ea54f | 2004-05-29 | Henrik Grubbström (Grubba) | | #else /* ! 0 */
if (p->constants[e].offset >= p->num_identifiers) {
Pike_fatal("Constant initializer outside num_identifiers (%d >= %d).\n",
p->constants[e].offset, p->num_identifiers);
}
#endif /* 0 */
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | }
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_strings;e++)
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | check_string(p->strings[e]);
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_inherits;e++)
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | {
|
13670c | 2015-05-25 | Martin Nilsson | | if(!p->inherits[e].prog)
|
ce277e | 2000-03-25 | Fredrik Hübinette (Hubbe) | | {
|
e05acb | 2000-03-25 | Fredrik Hübinette (Hubbe) | |
return;
|
ce277e | 2000-03-25 | Fredrik Hübinette (Hubbe) | | }
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | if(p->inherits[e].storage_offset < 0)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Inherit->storage_offset is wrong.\n");
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | | if(p->inherits[e].prog &&
p->inherits[e].storage_offset + STORAGE_NEEDED(p->inherits[e].prog) >
p->storage_needed)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Not enough room allocated by inherit!\n");
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | |
|
684bd2 | 2003-08-02 | Martin Stjernholm | | if (p->inherits[e].inherit_level == 1 &&
|
88e9fb | 2003-08-03 | Martin Stjernholm | | p->inherits[e].identifier_level != (INT32) p->inherits[e].identifier_ref_offset) {
|
684bd2 | 2003-08-02 | Martin Stjernholm | | dump_program_tables (p, 0);
Pike_fatal ("Unexpected difference between identifier_level "
"and identifier_ref_offset in inherit %d.\n", e);
}
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | if(e)
{
|
27ae84 | 2000-02-07 | Per Hedbor | | if(p->inherits[e-1].storage_offset >
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | p->inherits[e].storage_offset)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Overlapping inherits! (1)\n");
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | if(p->inherits[e-1].prog &&
|
27ae84 | 2000-02-07 | Per Hedbor | | p->inherits[e-1].inherit_level >= p->inherits[e].inherit_level &&
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | | ( p->inherits[e-1].storage_offset +
STORAGE_NEEDED(p->inherits[e-1].prog)) >
p->inherits[e].storage_offset)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Overlapping inherits! (3)\n");
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | }
}
|
29338d | 1999-09-29 | Henrik Grubbström (Grubba) | |
|
7066e1 | 1999-09-14 | Fredrik Hübinette (Hubbe) | | if(p->flags & PROGRAM_FINISHED)
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_identifiers;e++)
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | {
check_string(p->identifiers[e].name);
|
88e9fb | 2003-08-03 | Martin Stjernholm | | switch (p->identifiers[e].identifier_flags & IDENTIFIER_TYPE_MASK) {
case IDENTIFIER_VARIABLE:
case IDENTIFIER_PIKE_FUNCTION:
case IDENTIFIER_C_FUNCTION:
case IDENTIFIER_CONSTANT:
break;
default:
Pike_fatal("Invalid identifier type.\n");
}
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | if(p->identifiers[e].identifier_flags & ~IDENTIFIER_MASK)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Unknown flags in identifier flag field.\n");
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | |
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | if((p->identifiers[e].run_time_type!=T_MIXED) &&
|
2e1a6a | 2008-05-29 | Henrik Grubbström (Grubba) | | (p->identifiers[e].run_time_type!=PIKE_T_FREE) &&
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | (p->identifiers[e].run_time_type!=PIKE_T_GET_SET))
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | check_type(p->identifiers[e].run_time_type);
|
2f1b9e | 1998-04-06 | Fredrik Hübinette (Hubbe) | |
|
64dd45 | 2007-09-29 | Henrik Grubbström (Grubba) | | if (!IDENTIFIER_IS_ALIAS(p->identifiers[e].identifier_flags)) {
|
eb367a | 2007-09-25 | Henrik Grubbström (Grubba) | | if(IDENTIFIER_IS_VARIABLE(p->identifiers[e].identifier_flags))
|
2f1b9e | 1998-04-06 | Fredrik Hübinette (Hubbe) | | {
|
0fc3b9 | 2008-02-19 | Henrik Grubbström (Grubba) | | if((p->identifiers[e].func.offset ) &
|
eb367a | 2007-09-25 | Henrik Grubbström (Grubba) | | (alignof_variable(p->identifiers[e].run_time_type)-1))
{
|
938ae4 | 2008-02-02 | Henrik Grubbström (Grubba) | | dump_program_tables(p, 0);
|
eb367a | 2007-09-25 | Henrik Grubbström (Grubba) | | Pike_fatal("Variable %s offset is not properly aligned (%ld).\n",
p->identifiers[e].name->str,
|
6da27e | 2016-02-12 | Martin Nilsson | | (long)p->identifiers[e].func.offset);
|
eb367a | 2007-09-25 | Henrik Grubbström (Grubba) | | }
}
} else {
|
64dd45 | 2007-09-29 | Henrik Grubbström (Grubba) | | if (p->identifiers[e].func.ext_ref.depth &&
!(p->flags & PROGRAM_USES_PARENT)) {
|
eb367a | 2007-09-25 | Henrik Grubbström (Grubba) | | Pike_fatal("Identifier %d is an external reference, but "
"PROGRAM_USES_PARENT hasn't been set.\n",
e);
|
2f1b9e | 1998-04-06 | Fredrik Hübinette (Hubbe) | | }
}
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | }
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_identifier_references;e++)
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | {
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | struct identifier *i;
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | if(p->identifier_references[e].inherit_offset > p->num_inherits)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Inherit offset is wrong!\n");
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
513ece | 1999-09-09 | Fredrik Hübinette (Hubbe) | | if(!p->inherits[p->identifier_references[e].inherit_offset].prog)
{
if(!(p->flags & PROGRAM_FINISHED))
continue;
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("p->inherit[%d].prog = NULL!\n",p->identifier_references[e].inherit_offset);
|
513ece | 1999-09-09 | Fredrik Hübinette (Hubbe) | | }
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | if(p->identifier_references[e].identifier_offset >
p->inherits[p->identifier_references[e].inherit_offset].prog->num_identifiers)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Identifier offset %d is wrong! %d > %d\n",
|
19be9f | 2001-07-02 | Fredrik Hübinette (Hubbe) | | e,
p->identifier_references[e].identifier_offset,
p->inherits[p->identifier_references[e].inherit_offset].prog->num_identifiers);
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
i=ID_FROM_INT(p, e);
|
2de6f7 | 2008-02-14 | Henrik Grubbström (Grubba) | | if (IDENTIFIER_IS_ALIAS(i->identifier_flags)) {
if ((!i->func.ext_ref.depth) && (i->func.ext_ref.id == e)) {
dump_program_tables(p, 0);
Pike_fatal("Circular alias for reference %d!\n", e);
}
} else if (IDENTIFIER_IS_VARIABLE(i->identifier_flags)) {
|
63540d | 2000-08-15 | Henrik Grubbström (Grubba) | | size_t q, size;
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
63540d | 2000-08-15 | Henrik Grubbström (Grubba) | | ptrdiff_t offset = INHERIT_FROM_INT(p, e)->storage_offset+i->func.offset;
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | if (i->run_time_type == PIKE_T_GET_SET) {
struct reference *ref = PTR_FROM_INT(p, e);
|
f59012 | 2007-09-14 | Henrik Grubbström (Grubba) | | if (!ref->inherit_offset) {
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | | if (i->func.gs_info.getter >= p->num_identifier_references) {
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | Pike_fatal("Getter outside references.\n");
}
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | | if (i->func.gs_info.setter >= p->num_identifier_references) {
|
6fa59e | 2006-10-27 | Henrik Grubbström (Grubba) | | Pike_fatal("Setter outside references.\n");
}
}
continue;
}
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | size=sizeof_variable(i->run_time_type);
|
2e1a6a | 2008-05-29 | Henrik Grubbström (Grubba) | | if(size && ((offset+size > (size_t)p->storage_needed) || offset<0))
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Variable outside storage! (%s)\n",i->name->str);
|
e51d10 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
for(q=0;q<size;q++)
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | {
if(offset+q >= NELEM(variable_positions)) break;
if(variable_positions[offset+q] != -1)
{
if(ID_FROM_INT(p,variable_positions[offset+q])->run_time_type !=
i->run_time_type)
{
|
2d76f2 | 2005-05-20 | Martin Stjernholm | | fprintf(stderr, "Storage offset: "
"0x%08"PRINTPTRDIFFT"x vs 0x%08"PRINTPTRDIFFT"x\n"
"Func offset: 0x%08"PRINTPTRDIFFT"x vs 0x%08"PRINTPTRDIFFT"x\n"
|
2509e9 | 2001-07-02 | Henrik Grubbström (Grubba) | | "Type: %s vs %s\n",
INHERIT_FROM_INT(p, variable_positions[offset+q])->
storage_offset,
INHERIT_FROM_INT(p, e)->storage_offset,
ID_FROM_INT(p, variable_positions[offset+q])->func.offset,
i->func.offset,
get_name_of_type(ID_FROM_INT(p,variable_positions[offset+q]
)->run_time_type),
get_name_of_type(i->run_time_type));
|
66e2cf | 2001-06-10 | Henrik Grubbström (Grubba) | | if (i->name) {
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Variable '%s' and '%s' overlap\n"
|
2d76f2 | 2005-05-20 | Martin Stjernholm | | "Offset 0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x "
"overlaps with "
"0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x\n",
|
66e2cf | 2001-06-10 | Henrik Grubbström (Grubba) | | ID_FROM_INT(p, variable_positions[offset+q])->name->str,
|
062628 | 2001-07-02 | Henrik Grubbström (Grubba) | | i->name->str,
INHERIT_FROM_INT(p, variable_positions[offset+q])->
storage_offset +
ID_FROM_INT(p, variable_positions[offset+q])->func.offset,
INHERIT_FROM_INT(p, variable_positions[offset+q])->
storage_offset +
ID_FROM_INT(p, variable_positions[offset+q])->func.offset +
sizeof_variable(ID_FROM_INT(p, variable_positions[offset+q]
|
2653e8 | 2001-07-02 | Henrik Grubbström (Grubba) | | )->run_time_type)-1,
|
062628 | 2001-07-02 | Henrik Grubbström (Grubba) | | offset, offset+size-1);
|
66e2cf | 2001-06-10 | Henrik Grubbström (Grubba) | | } else {
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Variable '%s' and anonymous variable (%d) overlap\n"
|
2d76f2 | 2005-05-20 | Martin Stjernholm | | "Offset 0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x "
"overlaps with "
"0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x\n",
|
66e2cf | 2001-06-10 | Henrik Grubbström (Grubba) | | ID_FROM_INT(p, variable_positions[offset+q])->name->str,
|
062628 | 2001-07-02 | Henrik Grubbström (Grubba) | | e,
INHERIT_FROM_INT(p, variable_positions[offset+q])->
storage_offset +
ID_FROM_INT(p, variable_positions[offset+q])->func.offset,
INHERIT_FROM_INT(p, variable_positions[offset+q])->
storage_offset +
ID_FROM_INT(p, variable_positions[offset+q])->func.offset +
sizeof_variable(ID_FROM_INT(p, variable_positions[offset+q]
|
2653e8 | 2001-07-02 | Henrik Grubbström (Grubba) | | )->run_time_type)-1,
|
062628 | 2001-07-02 | Henrik Grubbström (Grubba) | | offset, offset+size-1);
|
66e2cf | 2001-06-10 | Henrik Grubbström (Grubba) | | }
|
68b695 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | }
}
variable_positions[offset+q]=e;
}
}
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | }
|
3c58e5 | 1999-09-22 | Henrik Grubbström (Grubba) | | for(e=0;e<p->num_identifier_index;e++)
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | {
if(p->identifier_index[e] > p->num_identifier_references)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program->identifier_indexes[%ld] is wrong\n",(long)e);
|
ab9db5 | 2003-02-20 | Henrik Grubbström (Grubba) | | if (e && (program_identifier_index_compare(p->identifier_index[e-1],
p->identifier_index[e],
p) > 0)) {
Pike_fatal("Program->identifier_index[%ld] > "
"Program->identifier_index[%ld]\n",
(long)(e-1), (long)e);
}
|
0d202a | 1995-10-20 | Fredrik Hübinette (Hubbe) | | }
}
#endif
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | static void f_dispatch_variant(INT32 args);
|
b70622 | 2014-08-20 | Henrik Grubbström (Grubba) | | int low_is_variant_dispatcher(struct identifier *id)
{
if (!id) return 0;
return (IDENTIFIER_IS_C_FUNCTION(id->identifier_flags) &&
!IDENTIFIER_IS_ALIAS(id->identifier_flags) &&
(id->func.c_fun == f_dispatch_variant));
}
|
a0a83a | 2013-06-16 | Henrik Grubbström (Grubba) | | int is_variant_dispatcher(struct program *prog, int fun)
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | | {
struct reference *ref;
struct identifier *id;
if (fun < 0) return 0;
ref = PTR_FROM_INT(prog, fun);
id = ID_FROM_PTR(prog, ref);
|
b70622 | 2014-08-20 | Henrik Grubbström (Grubba) | | return low_is_variant_dispatcher(id);
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | | }
static int add_variant_dispatcher(struct pike_string *name,
struct pike_type *type,
int id_flags)
{
union idptr dispatch_fun;
dispatch_fun.c_fun = f_dispatch_variant;
return define_function(name, type, id_flags & ~(ID_VARIANT|ID_LOCAL),
IDENTIFIER_C_FUNCTION, &dispatch_fun, 0);
}
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | |
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | * Identifier to annotate.
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | *
* @param val
* Annotation value. Should be an object implementing
* the Pike.Annotation interface.
*/
|
a88571 | 2019-02-09 | Henrik Grubbström (Grubba) | | PMOD_EXPORT void add_annotation(int id, struct svalue *val)
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | {
while (Pike_compiler->new_program->num_annotations <= id) {
add_to_annotations(NULL);
}
if (val) {
if (Pike_compiler->new_program->annotations[id]) {
|
b2dc95 | 2018-12-17 | Henrik Grubbström (Grubba) | | multiset_add(Pike_compiler->new_program->annotations[id], val);
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | } else {
push_svalue(val);
|
b2dc95 | 2018-12-17 | Henrik Grubbström (Grubba) | | f_aggregate_multiset(1);
Pike_compiler->new_program->annotations[id] = Pike_sp[-1].u.multiset;
Pike_sp--;
|
843d2f | 2018-11-06 | Henrik Grubbström (Grubba) | | }
}
}
void compiler_add_annotations(int id, node *annotations)
{
while(annotations) {
node *val_node = CAR(annotations);
annotations = CDR(annotations);
if (val_node->token != F_CONSTANT) continue;
add_annotation(id, &val_node->u.sval);
}
}
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | |
|
a88571 | 2019-02-09 | Henrik Grubbström (Grubba) | | PMOD_EXPORT void add_program_annotation(int inh, struct svalue *val)
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | {
struct inherit *inherit = Pike_compiler->new_program->inherits + inh;
if (inherit->inherit_level > 1) {
Pike_fatal("Attempt to annotate inherit #%d at level %d!\n",
inh, inherit->inherit_level);
}
if (val) {
if (inherit->annotations) {
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | | multiset_add(inherit->annotations, val);
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | } else {
push_svalue(val);
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | | f_aggregate_multiset(1);
inherit->annotations = Pike_sp[-1].u.multiset;
Pike_sp--;
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | }
}
}
void compiler_add_program_annotations(int inh, node *annotations)
{
while(annotations) {
node *val_node = CAR(annotations);
annotations = CDR(annotations);
if (val_node->token != F_CONSTANT) continue;
add_program_annotation(inh, &val_node->u.sval);
}
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | *
* 0: First pass.
* 1: Last pass.
* 2: Called from decode_value().
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | *
* Note: This function is misnamed, since it's run after all passes.
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | struct program *end_first_pass(int finish)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | | int e;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | struct program *prog = Pike_compiler->new_program;
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | | struct pike_string *init_name;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | int num_refs = prog->num_identifier_references;
union idptr dispatch_fun;
dispatch_fun.c_fun = f_dispatch_variant;
for (e = 0; e < num_refs; e++) {
struct identifier *id;
struct pike_string *name;
struct pike_type *type;
int id_flags;
|
2ad81f | 2013-12-12 | Henrik Grubbström (Grubba) | | int opt_flags;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | int j;
if (prog->identifier_references[e].inherit_offset) continue;
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | | if (!is_variant_dispatcher(prog, e)) continue;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | id = ID_FROM_INT(prog, e);
name = id->name;
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | | type = NULL;
id_flags = 0;
|
2ad81f | 2013-12-12 | Henrik Grubbström (Grubba) | | opt_flags = 0;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | |
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("Collecting variants of \"%s\"...\n", name->str);
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | |
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | |
j = prog->num_identifier_references;
while ((j = really_low_find_variant_identifier(name, prog, NULL, j,
SEE_PROTECTED|SEE_PRIVATE)) >= 0) {
struct reference *ref = prog->identifier_references + j;
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | id = ID_FROM_INT(prog, j);
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | | id_flags |= ref->id_flags;
|
2ad81f | 2013-12-12 | Henrik Grubbström (Grubba) | | opt_flags |= id->opt_flags;
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | |
|
358674 | 2016-10-30 | Henrik Grubbström (Grubba) | | ref->id_flags |= ID_LOCAL;
if (type)
|
9b4f21 | 2013-06-17 | Arne Goedeke | | {
|
358674 | 2016-10-30 | Henrik Grubbström (Grubba) | | struct pike_type * temp = type;
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if ((Pike_compiler->compiler_pass == COMPILER_PASS_LAST) &&
!ref->inherit_offset &&
|
358674 | 2016-10-30 | Henrik Grubbström (Grubba) | | !check_variant_overload(id->type, type)) {
yytype_report(REPORT_WARNING,
NULL, 0, NULL,
Pike_compiler->new_program->strings[id->filename_strno],
id->linenumber, id->type,
|
8173d4 | 2017-01-28 | Henrik Grubbström (Grubba) | | 0, "Function %S() masked by later variant.",
|
358674 | 2016-10-30 | Henrik Grubbström (Grubba) | | name);
ref_push_type_value(type);
low_yyreport(REPORT_WARNING,
Pike_compiler->new_program->strings[id->filename_strno],
id->linenumber,
type_check_system_string,
|
8173d4 | 2017-01-28 | Henrik Grubbström (Grubba) | | 1, "Variant : %O.");
|
358674 | 2016-10-30 | Henrik Grubbström (Grubba) | | }
type = or_pike_types(type, id->type, 1);
free_type(temp);
} else {
add_ref(type = id->type);
|
9b4f21 | 2013-06-17 | Arne Goedeke | | }
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | #ifdef COMPILER_DEBUG
fprintf(stderr, "type: ");
simple_describe_type(id->type);
fprintf(stderr, "\n");
#endif
}
#ifdef COMPILER_DEBUG
fprintf(stderr, "Dispatcher type: ");
simple_describe_type(type);
fprintf(stderr, "\n");
#endif
|
b3d2c2 | 2013-06-02 | Henrik Grubbström (Grubba) | |
id = ID_FROM_INT(prog, e);
free_type(id->type);
id->type = type;
|
2ad81f | 2013-12-12 | Henrik Grubbström (Grubba) | | id->opt_flags = opt_flags;
|
25df69 | 2014-04-16 | Henrik Grubbström (Grubba) | | prog->identifier_references[e].id_flags |= id_flags & ~(ID_VARIANT|ID_LOCAL);
|
b160c2 | 2013-05-26 | Henrik Grubbström (Grubba) | | next_ref:
;
}
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_compiler->fake_object);
debug_malloc_touch(Pike_compiler->fake_object->storage);
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | |
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | | init_name = lfun_strings[LFUN___INIT];
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
43680a | 2021-11-06 | Marcus Comstedt | | if (finish != 2) {
for(e=Pike_compiler->new_program->num_inherits-1;e;e--)
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
43680a | 2021-11-06 | Marcus Comstedt | | int id;
if(Pike_compiler->new_program->inherits[e].inherit_level!=1) continue;
id = FIND_LFUN(Pike_compiler->new_program->inherits[e].prog,
LFUN___INIT);
if(id!=-1)
{
id = really_low_reference_inherited_identifier(0, e, id);
Pike_compiler->init_node =
mknode(F_COMMA_EXPR,
mkcastnode(void_type_string,
mkapplynode(mkidentifiernode(id),0)),
Pike_compiler->init_node);
}
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
72a7dd | 2014-04-20 | Henrik Grubbström (Grubba) | | if (finish == 1) {
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass == COMPILER_PASS_FIRST) {
|
72a7dd | 2014-04-20 | Henrik Grubbström (Grubba) | |
if (Pike_compiler->init_node) {
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | | *
* Also make sure that it is marked as having side effects,
* or it will be optimized away when inherited...
|
72a7dd | 2014-04-20 | Henrik Grubbström (Grubba) | | */
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | | define_function(init_name, function_type_string, ID_PROTECTED,
IDENTIFIER_PIKE_FUNCTION, NULL,
OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);
|
72a7dd | 2014-04-20 | Henrik Grubbström (Grubba) | | }
}
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | |
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | Pike_compiler->compiler_pass = COMPILER_PASS_LAST;
|
72a7dd | 2014-04-20 | Henrik Grubbström (Grubba) | | }
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | | if (!Pike_compiler->num_parse_error) {
prog = Pike_compiler->new_program;
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | |
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | | if (prog->inherits->annotations) {
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | | struct multiset *l = prog->inherits->annotations;
ptrdiff_t pos;
for (pos = multiset_first(l); pos >= 0; pos = multiset_next(l, pos)) {
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | | struct object *o;
struct program *p;
struct inherit *inh;
int fun;
|
fa5b78 | 2018-12-16 | Henrik Grubbström (Grubba) | | push_multiset_index(l, pos);
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | | if (TYPEOF(Pike_sp[-1]) == PIKE_T_OBJECT) {
o = Pike_sp[-1].u.object;
p = o->prog;
if (p) {
inh = p->inherits + SUBTYPEOF(Pike_sp[-1]);
p = inh->prog;
fun = find_identifier("end_pass", p);
if (fun >= 0) {
fun += inh->identifier_level;
push_int(Pike_compiler->compiler_pass);
ref_push_program(prog);
ref_push_object_inherit(Pike_fp->current_object,
Pike_fp->context -
Pike_fp->current_program->inherits);
safe_apply_low2(o, fun, 3, NULL);
pop_stack();
}
}
}
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | | pop_stack();
}
|
ba275e | 2018-12-15 | Henrik Grubbström (Grubba) | |
sub_msnode_ref(l);
|
d5d858 | 2018-11-17 | Henrik Grubbström (Grubba) | | }
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
0ffa00 | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->init_node)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | |
|
dc8062 | 2002-11-14 | Henrik Grubbström (Grubba) | | Pike_compiler->compiler_frame->current_function_number = -2;
|
25b781 | 2014-04-20 | Henrik Grubbström (Grubba) | |
e=dooptcode(init_name,
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | mknode(F_COMMA_EXPR,
|
dc8062 | 2002-11-14 | Henrik Grubbström (Grubba) | | Pike_compiler->init_node,
mknode(F_RETURN,mkintnode(0),0)),
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | function_type_string,
|
95489a | 2008-06-29 | Martin Nilsson | | ID_PROTECTED);
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->init_node=0;
|
2659cf | 2002-05-10 | Henrik Grubbström (Grubba) | | } else if (finish == 2) {
e = low_find_lfun(Pike_compiler->new_program, LFUN___INIT);
|
b27025 | 2013-07-17 | Henrik Grubbström (Grubba) | | if ((e != -1) &&
(ID_FROM_INT(Pike_compiler->new_program, e)->func.offset == -1)) {
|
f9843b | 2013-07-17 | Henrik Grubbström (Grubba) | |
e = -1;
}
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | }else{
|
f9843b | 2013-07-17 | Henrik Grubbström (Grubba) | |
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | e=-1;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
c7565c | 2021-11-15 | Henrik Grubbström (Grubba) | |
|
c984a3 | 2019-12-07 | Henrik Grubbström (Grubba) | |
assert(!LFUN___INIT);
Pike_compiler->new_program->lfuns[Pike_compiler->new_program->lfuns[0]] = e;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_compiler_frame();
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->num_parse_error > 0)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) %p Compilation errors (%d).\n",
(long)th_self(), Pike_compiler->new_program,
Pike_compiler->num_parse_error);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | prog=0;
}else{
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | prog=Pike_compiler->new_program;
|
8c8337 | 1998-04-16 | Fredrik Hübinette (Hubbe) | | add_ref(prog);
|
558069 | 1996-06-21 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->flags |= PROGRAM_PASS_1_DONE;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
if(finish)
{
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->new_program->flags & PROGRAM_USES_PARENT)
{
|
91b959 | 2021-10-11 | Henrik Grubbström (Grubba) | | if (!Pike_compiler->new_program->parent_info_storage) {
Pike_compiler->new_program->parent_info_storage =
add_xstorage(sizeof(struct parent_info),
ALIGNOF(struct parent_info),
0);
}
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | }else{
Pike_compiler->new_program->parent_info_storage=-1;
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | fixate_program();
|
3b7d18 | 2001-09-26 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->num_parse_error)
{
free_program(prog);
prog=0;
}else{
optimize_program(Pike_compiler->new_program);
Pike_compiler->new_program->flags |= PROGRAM_FINISHED;
}
|
aaf40c | 2013-11-03 | Henrik Grubbström (Grubba) | | } else {
for (e = 0; e < prog->num_identifier_references; e++) {
struct reference *ref = prog->identifier_references + e;
if (ref->id_flags & ID_HIDDEN) continue;
if (ref->inherit_offset != 0) continue;
override_identifier (ref, ID_FROM_PTR (prog, ref)->name,
ID_EXTERN);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
aa771b | 2003-08-20 | Martin Stjernholm | | #ifdef PIKE_DEBUG
|
4c4f93 | 2005-05-26 | Martin Stjernholm | | if (prog) {
check_program(prog);
if(l_flag)
dump_program_desc(prog);
}
|
aa771b | 2003-08-20 | Martin Stjernholm | | #endif
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
a78643 | 1999-11-18 | Martin Stjernholm | |
#ifdef PROGRAM_BUILD_DEBUG
|
8411e5 | 2017-01-28 | Henrik Grubbström (Grubba) | | fprintf (stderr, "%*sfinishing program %d (pass=%d)\n",
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth, "",
Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
|
a78643 | 1999-11-18 | Martin Stjernholm | | #endif
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | toss_compilation_resources();
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
cb6704 | 2001-12-12 | Martin Stjernholm | | #if 0
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) end_first_pass(): "
"%p compilation_depth:%d, Pike_compiler->compiler_pass:%d\n",
(long)th_self(), prog,
c->compilation_depth, Pike_compiler->compiler_pass);
|
cb6704 | 2001-12-12 | Martin Stjernholm | | #endif
|
aed42d | 1999-12-29 | Martin Stjernholm | |
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if(!Pike_compiler->compiler_frame &&
(Pike_compiler->compiler_pass == COMPILER_PASS_LAST || !prog) &&
c->resolve_cache)
|
aed42d | 1999-12-29 | Martin Stjernholm | | {
|
518b04 | 2011-11-20 | Henrik Grubbström (Grubba) | | free_mapping(dmalloc_touch(struct mapping *, c->resolve_cache));
c->resolve_cache=0;
|
aed42d | 1999-12-29 | Martin Stjernholm | | }
|
5c8e89 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | #define POP
#include "compilation.h"
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
fb2f66 | 1998-11-05 | Fredrik Hübinette (Hubbe) | | exit_type_stack();
|
05590d | 1998-04-23 | Fredrik Hübinette (Hubbe) | |
|
61bd38 | 2004-09-27 | Henrik Grubbström (Grubba) | |
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) %p end_first_pass(%d): "
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | "compilation_depth:%d\n",
|
a91d9a | 2016-01-11 | Martin Nilsson | | (long)th_self(), prog, finish,
|
b0e9e9 | 2018-12-21 | Henrik Grubbström (Grubba) | | c->compilation_depth);
|
b3cca7 | 2001-06-14 | Henrik Grubbström (Grubba) | |
|
885388 | 2008-04-26 | Henrik Grubbström (Grubba) | | c->compilation_depth--;
|
a91ca0 | 1998-07-10 | Henrik Grubbström (Grubba) | |
|
8b5b3a | 2014-04-28 | Henrik Grubbström (Grubba) | | unlock_pike_compiler();
|
ea32c1 | 1998-04-13 | Henrik Grubbström (Grubba) | |
|
29d1e6 | 2005-05-31 | Henrik Grubbström (Grubba) | | #if 0
#ifdef PIKE_USE_MACHINE_CODE
if (prog &&
(((unsigned long long *)prog->program)[-1] != 0xdeadfeedf00dfaddLL)) {
Pike_fatal("Bad mexec magic!\n");
}
#endif /* PIKE_USE_MACHINE_CODE */
#endif /* 0 */
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return prog;
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | * Finish this program, returning the newly built program
*/
|
1f2133 | 2000-07-28 | Fredrik Hübinette (Hubbe) | | PMOD_EXPORT struct program *debug_end_program(void)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
return end_first_pass(1);
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
6f9669 | 2009-09-12 | Henrik Grubbström (Grubba) | | * Allocate space needed for this program in the object structure.
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | * An offset to the data is returned.
*/
|
b81935 | 2000-08-14 | Henrik Grubbström (Grubba) | | PMOD_EXPORT size_t low_add_storage(size_t size, size_t alignment,
ptrdiff_t modulo_orig)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
d3b06f | 2000-08-10 | Henrik Grubbström (Grubba) | | ptrdiff_t offset;
ptrdiff_t modulo;
|
2ad3c0 | 1999-09-16 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(!size) return Pike_compiler->new_program->storage_needed;
|
2ad3c0 | 1999-09-16 | Fredrik Hübinette (Hubbe) | |
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
if(alignment <=0 || (alignment & (alignment-1)) || alignment > 256)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Alignment must be 1,2,4,8,16,32,64,128 or 256 not %ld\n",
|
6da27e | 2016-02-12 | Martin Nilsson | | (long)alignment);
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | #endif
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | | modulo=( modulo_orig ) % alignment;
|
b1c803 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | offset=DO_ALIGN(Pike_compiler->new_program->storage_needed-modulo,alignment)+modulo;
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(!Pike_compiler->new_program->storage_needed) {
|
29338d | 1999-09-29 | Henrik Grubbström (Grubba) | | * Otherwise the debug code below ought to be trigged.
* But since it isn't, I guess this is dead code?
* /grubba 1999-09-28
|
eb071e | 1999-09-28 | Fredrik Hübinette (Hubbe) | | *
* No, the below offset represents the storage in the beginning
* of obj->storage which is not used because of alignment constraints.
* However, for historical reasons, prog->storage_offset needs to
* contain this unused space as well. This means that the real
* space used by all variables in an object is really:
* o->prog->storage_needed - o->prog->inherits[0].storage_offset,
* This can also be written as STORAGE_NEEDED(o->prog)
* STORAGE_NEEDED() is defined in program.h.
* /Hubbe 1999-09-29
|
0ee233 | 1999-09-29 | Henrik Grubbström (Grubba) | | *
* Oops, seems I read the test below the wrong way around.
* /grubba 1999-09-29
|
29338d | 1999-09-29 | Henrik Grubbström (Grubba) | | */
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->inherits[0].storage_offset=offset;
|
29338d | 1999-09-29 | Henrik Grubbström (Grubba) | | }
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->new_program->alignment_needed<alignment)
|
bd6739 | 2015-10-14 | Martin Nilsson | | Pike_compiler->new_program->alignment_needed = (unsigned INT8)alignment;
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(offset < Pike_compiler->new_program->storage_needed)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("add_storage failed horribly!\n");
|
b1c803 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | | if( (offset - modulo_orig ) % alignment )
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("add_storage failed horribly(2) %ld %ld %ld %ld!\n",
|
bd6739 | 2015-10-14 | Martin Nilsson | | (long)offset,
|
648a1a | 2000-06-22 | Fredrik Hübinette (Hubbe) | | (long)0 ,
|
df02f1 | 2015-10-17 | Henrik Grubbström (Grubba) | | (long)modulo_orig,
|
bd6739 | 2015-10-14 | Martin Nilsson | | (long)alignment);
|
27ae84 | 2000-02-07 | Per Hedbor | |
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | | #endif
|
b1c803 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->storage_needed = offset + size;
|
b1c803 | 1999-09-15 | Fredrik Hübinette (Hubbe) | |
|
b81935 | 2000-08-14 | Henrik Grubbström (Grubba) | | return (size_t) offset;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | |
|
91b959 | 2021-10-11 | Henrik Grubbström (Grubba) | | size_t add_xstorage(size_t size,
size_t alignment,
ptrdiff_t modulo_orig)
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | {
ptrdiff_t offset, modulo, available;
int e;
if(!size) return Pike_compiler->new_program->xstorage;
modulo=( modulo_orig ) % alignment;
offset=DO_ALIGN(Pike_compiler->new_program->xstorage-modulo,alignment)+modulo;
Pike_compiler->new_program->xstorage = offset + size;
available = Pike_compiler->new_program->inherits[0].storage_offset;
|
21fdac | 2001-05-02 | Henrik Grubbström (Grubba) | | if(available < (ptrdiff_t)(offset+size))
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | {
available=
|
13670c | 2015-05-25 | Martin Nilsson | | DO_ALIGN( ((offset + size) - available),
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->alignment_needed);
|
13670c | 2015-05-25 | Martin Nilsson | |
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | for(e=0;e<Pike_compiler->new_program->num_inherits;e++)
Pike_compiler->new_program->inherits[e].storage_offset+=available;
Pike_compiler->new_program->storage_needed+=available;
}
|
13670c | 2015-05-25 | Martin Nilsson | |
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | return (size_t) offset;
}
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | typedef void (*oldhandlertype)(struct object *);
|
a54789 | 2007-05-13 | Martin Stjernholm | |
|
99cce5 | 2007-05-26 | Martin Stjernholm | | static void compat_event_handler(int e)
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | {
oldhandlertype handler;
|
d0787c | 2001-09-20 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_fp->current_object);
|
fa93a5 | 2008-02-28 | Henrik Grubbström (Grubba) | | handler=((oldhandlertype *)Pike_fp->context->prog->program)[e];
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | if(handler) handler(Pike_fp->current_object);
|
d0787c | 2001-09-20 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(Pike_fp->current_object);
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | }
static void add_compat_event_handler(void)
{
if(Pike_compiler->new_program->event_handler != compat_event_handler)
{
unsigned int e,d;
unsigned char *tmp=(unsigned char *)&Pike_compiler->new_program->event_handler;
|
6d727b | 2001-07-08 | Henrik Grubbström (Grubba) | | for(d=0;d<NUM_PROG_EVENTS;d++) {
|
b5dc81 | 2001-07-12 | Fredrik Hübinette (Hubbe) | |
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | for(e=0;e<sizeof(Pike_compiler->new_program->event_handler);e++)
add_to_program(tmp[e]);
|
13670c | 2015-05-25 | Martin Nilsson | | }
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->event_handler=compat_event_handler;
}
}
|
199498 | 1998-04-07 | Fredrik Hübinette (Hubbe) | |
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
a54789 | 2007-05-13 | Martin Stjernholm | | * Set a callback to be called when this program is cloned.
*
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * This function is obsolete; see pike_set_prog_event_callback for
* details.
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | */
|
1f2133 | 2000-07-28 | Fredrik Hübinette (Hubbe) | | PMOD_EXPORT void set_init_callback(void (*init)(struct object *))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | add_compat_event_handler();
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(0);
#endif
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_INIT]=init;
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(1);
#endif
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
a54789 | 2007-05-13 | Martin Stjernholm | | * Set a callback to be called when clones of this program are
* destructed.
*
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * This function is obsolete; see pike_set_prog_event_callback for
* details.
*
* Note: If the callback only does very trivial stuff, like freeing or
* clearing a few pointers in the object storage, you can do
*
* Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;
*
* after the set_exit_callback call. That allows the gc to operate
* more efficiently, but the effect is that the callback might be
* called out of order for PROG_EVENT_EXIT events; see the docs for
* PROGRAM_LIVE_OBJ in program.h for further details.
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | */
|
1f2133 | 2000-07-28 | Fredrik Hübinette (Hubbe) | | PMOD_EXPORT void set_exit_callback(void (*exit)(struct object *))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | add_compat_event_handler();
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(0);
#endif
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_EXIT]=exit;
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(1);
#endif
|
99cce5 | 2007-05-26 | Martin Stjernholm | | Pike_compiler->new_program->flags |= PROGRAM_LIVE_OBJ;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
e2d9e6 | 2000-06-10 | Martin Stjernholm | | * This callback is used by the gc to traverse all references to
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | * things in memory. It should call some gc_recurse_* function exactly
* once for each reference that the pike internals doesn't know about.
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | *
* If a reference is shared between objects, it should be traversed
* once for every instance sharing it.
*
* The callback might be called more than once for the same instance
* during a gc pass. The gc assumes that the references are enumerated
* in the same order in that case.
|
03bcb9 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | *
|
a9ae57 | 2004-04-04 | Martin Stjernholm | | * The callback is called after any mapped variables on the object
* have been recursed (and possibly freed).
*
|
5e8344 | 2008-05-11 | Martin Stjernholm | | * If there are pointers to allocated memory that you keep track of on
* the C level then you should add something like this to the recurse
* callback so that Pike.count_memory remains accurate:
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | *
|
906149 | 2008-06-23 | Martin Stjernholm | | * if (mc_count_bytes (Pike_fp->current_object))
|
5e8344 | 2008-05-11 | Martin Stjernholm | | * mc_counted_bytes += <size of the allocated memory block(s)>
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | *
* If the allocated memory is shared between objects then it gets more
|
5e8344 | 2008-05-11 | Martin Stjernholm | | * complicated and you need to write visit_thing_fn callbacks. See
* e.g. visit_mapping and visit_mapping_data for how to do that.
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | *
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * This function is obsolete; see pike_set_prog_event_callback for
* details.
|
d4828c | 1997-07-17 | Fredrik Hübinette (Hubbe) | | */
|
1f2133 | 2000-07-28 | Fredrik Hübinette (Hubbe) | | PMOD_EXPORT void set_gc_recurse_callback(void (*m)(struct object *))
|
d4828c | 1997-07-17 | Fredrik Hübinette (Hubbe) | | {
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | add_compat_event_handler();
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(0);
#endif
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_GC_RECURSE]=m;
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(1);
#endif
|
d4828c | 1997-07-17 | Fredrik Hübinette (Hubbe) | | }
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
ad8d05 | 2008-05-02 | Martin Stjernholm | | * This callback is used by the gc to count all references to things
* in memory. It should call gc_check, gc_check_(weak_)svalues or
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | * gc_check_(weak_)short_svalue exactly once for each reference that
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | * the pike internals don't know about.
|
e2d9e6 | 2000-06-10 | Martin Stjernholm | | *
* If a reference is shared between objects, it should be counted once
* for all shared instances. The return value from gc_check is useful
* to ensure this; it's zero when called the first time for its
|
ad8d05 | 2008-05-02 | Martin Stjernholm | | * argument (it is perfectly fine to use gc_check on things that the
* pike core doesn't know about, but they must have an INT32 refcount
* first).
|
03bcb9 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | *
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * This function is obsolete; see pike_set_prog_event_callback for
* details.
|
f0c3d3 | 1998-04-05 | Fredrik Hübinette (Hubbe) | | */
|
1f2133 | 2000-07-28 | Fredrik Hübinette (Hubbe) | | PMOD_EXPORT void set_gc_check_callback(void (*m)(struct object *))
|
f0c3d3 | 1998-04-05 | Fredrik Hübinette (Hubbe) | | {
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | add_compat_event_handler();
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(0);
#endif
|
763f68 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_GC_CHECK]=m;
|
c11f16 | 2021-01-04 | Marcus Comstedt | | #ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
pthread_jit_write_protect_np(1);
#endif
|
f0c3d3 | 1998-04-05 | Fredrik Hübinette (Hubbe) | | }
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
a54789 | 2007-05-13 | Martin Stjernholm | | * Set a callback to be called when any of the special program events
* occur. The event type is sent as an integer argument. The events
* include, but might not be limited to, the following:
*
* PROG_EVENT_INIT
* An object is being cloned from the program. See set_init_callback
* for details.
* PROG_EVENT_EXIT
* An object is being destructed. See set_exit_callback for details.
* PROG_EVENT_GC_RECURSE
* An object is being recursed by the gc. See
* set_gc_recurse_callback for details.
* PROG_EVENT_GC_CHECK
* An object is being checked by the gc. See set_gc_check_callback
* for details.
*
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * Note that installing an event callback will set the
* PROGRAM_LIVE_OBJ flag since the callback might act on the
* PROG_EVENT_EXIT event. If the callback won't do anything for that
* event (or if it only does something very trivial for it), you
* should do
*
* Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;
|
a54789 | 2007-05-13 | Martin Stjernholm | | *
|
99cce5 | 2007-05-26 | Martin Stjernholm | | * afterwards to clear it again. That allows the gc to operate more
* efficiently, but the effect is that the callback might be called
* out of order for PROG_EVENT_EXIT events; see the docs for
* PROGRAM_LIVE_OBJ in program.h for further details.
|
a54789 | 2007-05-13 | Martin Stjernholm | | */
|
f13b95 | 2006-07-05 | Martin Stjernholm | | PMOD_EXPORT void pike_set_prog_event_callback(void (*cb)(int))
|
03bcb9 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | {
#ifdef PIKE_DEBUG
if(Pike_compiler->new_program->event_handler)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program already has an event handler!\n");
|
03bcb9 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | #endif
Pike_compiler->new_program->event_handler=cb;
|
99cce5 | 2007-05-26 | Martin Stjernholm | | Pike_compiler->new_program->flags |= PROGRAM_LIVE_OBJ;
|
03bcb9 | 2001-03-12 | Fredrik Hübinette (Hubbe) | | }
|
f13b95 | 2006-07-05 | Martin Stjernholm | | PMOD_EXPORT void pike_set_prog_optimize_callback(node *(*opt)(node *))
|
a5d45c | 2001-05-26 | Henrik Grubbström (Grubba) | | {
#ifdef PIKE_DEBUG
if(Pike_compiler->new_program->optimize)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Program already has an optimize handler!\n");
|
a5d45c | 2001-05-26 | Henrik Grubbström (Grubba) | | #endif
Pike_compiler->new_program->optimize = opt;
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
b524e2 | 2019-03-29 | Henrik Grubbström (Grubba) | | * Returns an equivalent reference that is INLINE (and HIDDEN if
* a new reference was created).
|
77bdad | 2015-05-15 | Henrik Grubbström (Grubba) | | *
* Returns -1 if the referenced identifier is -1 or a prototype.
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | */
|
b0c1a0 | 2013-10-28 | Henrik Grubbström (Grubba) | | PMOD_EXPORT int really_low_reference_inherited_identifier(struct program_state *q,
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | | int i,
int f)
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | {
struct program *np=(q?q:Pike_compiler)->new_program;
struct reference funp;
struct program *p;
int d, num_id_refs;
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | | if(f==-1) return -1;
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | |
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | | p = np->inherits[i].prog;
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | |
|
bdfe4e | 2017-12-11 | Henrik Grubbström (Grubba) | | if ((q?q:Pike_compiler)->compiler_pass == COMPILER_PASS_LAST) {
|
91c329 | 2015-05-15 | Henrik Grubbström (Grubba) | | struct identifier *id = ID_FROM_INT(p, f);
|
77bdad | 2015-05-15 | Henrik Grubbström (Grubba) | | if (((id->identifier_flags & IDENTIFIER_TYPE_MASK) ==
IDENTIFIER_PIKE_FUNCTION) && (id->func.offset == -1)) {
return -1;
}
}
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | | funp = p->identifier_references[f];
funp.inherit_offset += i;
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | funp.id_flags = (funp.id_flags & ~ID_INHERITED) | ID_INLINE|ID_HIDDEN;
num_id_refs = np->num_identifier_references;
for(d = 0; d < num_id_refs; d++)
{
struct reference *refp;
refp = np->identifier_references + d;
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | if ((refp->inherit_offset == funp.inherit_offset) &&
(refp->identifier_offset == funp.identifier_offset) &&
|
b524e2 | 2019-03-29 | Henrik Grubbström (Grubba) | | ((refp->id_flags & (ID_INLINE|ID_EXTERN|ID_VARIANT)) ==
(funp.id_flags & (ID_INLINE|ID_EXTERN|ID_VARIANT)))) {
|
1f7f17 | 2007-10-11 | Henrik Grubbström (Grubba) | | return d;
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | | }
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | }
|
77fbd7 | 2010-11-25 | Henrik Grubbström (Grubba) | | funp.run_time_type = PIKE_T_UNKNOWN;
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | if(q)
low_add_to_identifier_references(q,funp);
else
add_to_identifier_references(funp);
#ifdef PIKE_DEBUG
if (num_id_refs != np->num_identifier_references-1) {
|
a6f229 | 2016-01-29 | Martin Nilsson | | Pike_fatal("Unexpected number of identifier references: %d != %d\n",
num_id_refs, np->num_identifier_references-1);
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | }
#endif /* PIKE_DEBUG */
|
8029d7 | 2013-10-31 | Henrik Grubbström (Grubba) | |
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | return num_id_refs;
}
|
b0c1a0 | 2013-10-28 | Henrik Grubbström (Grubba) | | PMOD_EXPORT int low_reference_inherited_identifier(struct program_state *q,
int e,
|
9fca41 | 2017-07-31 | Martin Nilsson | | struct pike_string *name,
|
b0c1a0 | 2013-10-28 | Henrik Grubbström (Grubba) | | int flags)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | struct program *np=(q?q:Pike_compiler)->new_program;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | struct program *p;
|
6ce732 | 2008-07-16 | Martin Stjernholm | | int i;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | p=np->inherits[e].prog;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | i=find_shared_string_identifier(name,p);
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | if(i==-1)
{
|
8aae6d | 1999-08-19 | Fredrik Hübinette (Hubbe) | | i=really_low_find_shared_string_identifier(name,p, flags);
|
c0e446 | 1998-06-23 | Fredrik Hübinette (Hubbe) | | if(i==-1) return -1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7fda7a | 1997-09-08 | Fredrik Hübinette (Hubbe) | | if(p->identifier_references[i].id_flags & ID_HIDDEN)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return -1;
|
8aae6d | 1999-08-19 | Fredrik Hübinette (Hubbe) | | if(p->identifier_references[i].id_flags & ID_PRIVATE)
if(!(flags & SEE_PRIVATE))
return -1;
|
3a3eac | 2004-01-19 | Henrik Grubbström (Grubba) | | return really_low_reference_inherited_identifier(q, e, i);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
9fca41 | 2017-07-31 | Martin Nilsson | | int find_inherit(const struct program *p, const struct pike_string *name)
|
9a3e73 | 2000-06-26 | Henrik Grubbström (Grubba) | | {
int e;
|
6716b8 | 2013-11-08 | Henrik Grubbström (Grubba) | | int level = p->num_inherits;
int res = 0;
|
9a3e73 | 2000-06-26 | Henrik Grubbström (Grubba) | |
|
ba8c39 | 2000-06-26 | Henrik Grubbström (Grubba) | | #if 0
fprintf(stderr, "find_inherit(0x%08lx, \"%s\")...\n",
(unsigned long)p, name->str);
#endif /* 0 */
|
6716b8 | 2013-11-08 | Henrik Grubbström (Grubba) | |
|
ba8c39 | 2000-06-26 | Henrik Grubbström (Grubba) | | for(e = p->num_inherits-1; e>0; e--) {
#if 0
fprintf(stderr, " %04d: %04d %s\n",
e, p->inherits[e].inherit_level,
p->inherits[e].name?p->inherits[e].name->str:"NULL");
#endif /* 0 */
|
6716b8 | 2013-11-08 | Henrik Grubbström (Grubba) | | if (p->inherits[e].inherit_level >= level) continue;
if (name == p->inherits[e].name) {
res = e;
level = p->inherits[e].inherit_level;
if (level == 1) break;
}
|
9a3e73 | 2000-06-26 | Henrik Grubbström (Grubba) | | }
|
6716b8 | 2013-11-08 | Henrik Grubbström (Grubba) | | return res;
|
9a3e73 | 2000-06-26 | Henrik Grubbström (Grubba) | | }
|
4547a2 | 2019-06-27 | Henrik Grubbström (Grubba) | |
PMOD_EXPORT int find_inherited_prog(const struct program *p,
const struct program *wanted)
{
int e;
int level = p->num_inherits;
int res = -1;
if (UNLIKELY(!p || !wanted)) return -1;
if (p == wanted) return 0;
for(e = p->num_inherits-1; e>0; e--) {
if (p->inherits[e].inherit_level >= level) continue;
if (p->inherits[e].prog == wanted) {
res = e;
level = p->inherits[e].inherit_level;
if (level == 1) break;
}
}
return res;
}
PMOD_EXPORT int find_inherited_fun(const struct program *p, int inherit_number,
const struct program *wanted, int fun)
{
int e;
if (UNLIKELY(!p || !wanted || (fun < 0))) return -1;
e = find_inherited_prog(p->inherits[inherit_number].prog, wanted);
if (UNLIKELY(e < 0)) {
struct identifier *id = ID_FROM_INT(wanted, fun);
fun = find_shared_string_identifier(id->name,
p->inherits[inherit_number].prog);
if (fun < 0) return -1;
}
return fun + p->inherits[inherit_number + e].identifier_level;
}
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | |
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | * specified by state.
*
|
29615e | 2014-10-18 | Henrik Grubbström (Grubba) | | * @return Returns the reference in state->new_program if found.
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | */
PMOD_EXPORT int reference_inherited_identifier(struct program_state *state,
struct pike_string *inherit,
struct pike_string *name)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | int e, id;
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | | struct program *p;
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
33e873 | 2015-12-25 | Henrik Grubbström (Grubba) | | if (name != debug_findstring(name))
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | Pike_fatal("reference_inherited_identifier on nonshared string.\n");
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #endif
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | |
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | if (!state) state = Pike_compiler;
|
4c083b | 2013-04-28 | Henrik Grubbström (Grubba) | | p = state->new_program;
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | |
|
6f9669 | 2009-09-12 | Henrik Grubbström (Grubba) | |
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | for (e = p->num_inherits; e--;) {
if (p->inherits[e].inherit_level != 1) continue;
if (inherit && (inherit != p->inherits[e].name)) continue;
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | |
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | id = low_reference_inherited_identifier(state, e, name, SEE_PROTECTED);
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | |
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | if (id != -1) return id;
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | }
|
6d0fdb | 2013-04-28 | Henrik Grubbström (Grubba) | | return -1;
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | }
|
6f9669 | 2009-09-12 | Henrik Grubbström (Grubba) | |
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | void rename_last_inherit(struct pike_string *n)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->new_program->inherits[Pike_compiler->new_program->num_inherits].name)
free_string(Pike_compiler->new_program->inherits[Pike_compiler->new_program->num_inherits].name);
copy_shared_string(Pike_compiler->new_program->inherits[Pike_compiler->new_program->num_inherits].name,
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | n);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
88e9fb | 2003-08-03 | Martin Stjernholm | | #if 0
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | static int locate_parent_state(struct program_state **state,
struct inherit **i,
int *parent_identifier,
int depth)
{
int result=1;
if(depth<=0) return depth;
while(depth-->0)
{
|
684bd2 | 2003-08-02 | Martin Stjernholm | | if( (*i)->parent_offset != INHERIT_PARENT)
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | {
int tmp=(*i)->parent_identifier;
if( (*i)->parent_offset > 0)
{
int po=(*i)->parent_offset;
*parent_identifier = (*state)->parent_identifier;
*state = (*state)->previous;
result++;
fprintf(stderr,"INHERIT: state=state->previous (po=%d)\n",po);
if(po>1)
{
*i=INHERIT_FROM_INT( (*state)->new_program,
*parent_identifier);
result+=locate_parent_state(state,i,parent_identifier, po-1);
}
}
if(tmp != -1)
{
if( *parent_identifier == -4711)
{
*parent_identifier = tmp;
}else{
*parent_identifier = tmp + INHERIT_FROM_INT( (*state)->new_program,
*parent_identifier)->identifier_level;
}
}
}else{
fprintf(stderr,"INHERIT: Bailout!\n");
return result+depth+1;
}
*i = INHERIT_FROM_INT( (*state)->new_program, *parent_identifier);
}
return result;
}
static int find_depth(struct program_state *state,
struct inherit *i,
int parent_identifier,
int depth)
{
#if 0
int e;
struct inherit *oi;
for(e=0;e<=parent_offset;e++) state=state->previous;
oi=INHERIT_FROM_INT(state->new_program, parent_identifier);
parent_offset+=i->parent_offset;
#endif
return locate_parent_state(&state,
&i,
&parent_identifier,
depth);
}
|
88e9fb | 2003-08-03 | Martin Stjernholm | | #endif
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
a0c9f6 | 2013-06-15 | Henrik Grubbström (Grubba) | | void lower_inherit(struct program *p,
struct object *parent,
int parent_identifier,
int parent_offset,
INT32 flags,
struct pike_string *name)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
d3b06f | 2000-08-10 | Henrik Grubbström (Grubba) | | int e;
ptrdiff_t inherit_offset, storage_offset;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | struct inherit inherit;
|
02a79a | 2000-09-04 | Fredrik Hübinette (Hubbe) | | #if 0
|
0f2b44 | 2001-12-14 | Martin Stjernholm | | fprintf(stderr,"%p low_inherit(pid=%d, parent=%p, parid=%d, "
"paroff=%d, flags=0x%x, name=%s);\n",
Pike_compiler->new_program,
p ? p->id : 0,
|
02a79a | 2000-09-04 | Fredrik Hübinette (Hubbe) | | parent,
parent_identifier,
parent_offset,
flags,
name? name->str : "");
#endif
|
a91d9a | 2016-01-11 | Martin Nilsson | | CDFPRINTF("th(%ld) %p inherit %p\n",
(long) th_self(), Pike_compiler->new_program, p);
|
13670c | 2015-05-25 | Martin Nilsson | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!p)
{
yyerror("Illegal program pointer.");
return;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass != COMPILER_PASS_FIRST) {
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | struct program *old_p =
|
97ffb3 | 2017-12-20 | Henrik Grubbström (Grubba) | | Pike_compiler->new_program->
inherits[Pike_compiler->num_inherits+1].prog;
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | inherit_offset = Pike_compiler->num_inherits + 1;
|
97ffb3 | 2017-12-20 | Henrik Grubbström (Grubba) | | Pike_compiler->num_inherits += old_p->num_inherits;
if (old_p != p) {
yyerror("Got different program for inherit in second pass "
"(resolver problem).");
}
|
73a685 | 2008-08-15 | Martin Stjernholm | |
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_pass == COMPILER_PASS_EXTRA) {
return;
|
73a685 | 2008-08-15 | Martin Stjernholm | | }
|
f2477f | 2018-11-16 | Henrik Grubbström (Grubba) | | assert(Pike_compiler->compiler_pass == COMPILER_PASS_LAST);
|
73a685 | 2008-08-15 | Martin Stjernholm | | if (!(p->flags & PROGRAM_FINISHED)) {
yyerror ("Cannot inherit program in pass 2 "
"which is not fully compiled yet.");
yyerror ("(You probably have a cyclic symbol dependency that the "
"compiler cannot handle.)");
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | }
|
73a685 | 2008-08-15 | Martin Stjernholm | |
|
7c3fe0 | 2009-11-20 | Henrik Grubbström (Grubba) | |
if(p->flags & PROGRAM_NEEDS_PARENT)
{
struct program_state *state=Pike_compiler;
if(!parent && !parent_offset)
{
yyerror("Parent pointer lost, cannot inherit!");
}
#if 0
for(e=0;e<c->compilation_depth;e++,state=state->previous)
state->new_program->flags |= PROGRAM_USES_PARENT;
#endif
}
|
73a685 | 2008-08-15 | Martin Stjernholm | | return;
}
if (!(p->flags & (PROGRAM_FINISHED | PROGRAM_PASS_1_DONE))) {
yyerror ("Cannot inherit program in pass 1 "
"which is only a placeholder.");
yyerror ("(You probably have a cyclic symbol dependency that the "
"compiler cannot handle.)");
|
d16515 | 2008-05-03 | Henrik Grubbström (Grubba) | | return;
}
|
bd537b | 2002-12-10 | Martin Stjernholm | | if (p == placeholder_program) {
yyerror("Trying to inherit placeholder program (resolver problem).");
return;
}
|
0f2b44 | 2001-12-14 | Martin Stjernholm | |
|
6a66f8 | 2018-08-05 | Marcus Comstedt | |
if (p->flags & (PROGRAM_HAS_C_METHODS|PROGRAM_CLEAR_STORAGE|PROGRAM_DESTRUCT_IMMEDIATE)) {
|
a94712 | 2014-06-16 | Henrik Grubbström (Grubba) | | Pike_compiler->new_program->flags |=
|
6a66f8 | 2018-08-05 | Marcus Comstedt | | (p->flags & (PROGRAM_HAS_C_METHODS|PROGRAM_CLEAR_STORAGE|PROGRAM_DESTRUCT_IMMEDIATE));
|
d8e7d8 | 2013-10-05 | Henrik Grubbström (Grubba) | | }
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
313989 | 1999-09-06 | Henrik Grubbström (Grubba) | | if(parent_offset)
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | parent_offset-=42;
|
199425 | 1999-09-06 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | inherit_offset = Pike_compiler->new_program->num_inherits;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
9386f7 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | storage_offset=p->inherits[0].storage_offset % p->alignment_needed;
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | | storage_offset=low_add_storage(STORAGE_NEEDED(p),
|
90e978 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | p->alignment_needed,
|
b1c803 | 1999-09-15 | Fredrik Hübinette (Hubbe) | | storage_offset);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | |
|
27ae84 | 2000-02-07 | Per Hedbor | | storage_offset-=p->inherits[0].storage_offset;
|
1f5bfe | 1999-09-28 | Fredrik Hübinette (Hubbe) | |
|
5c8e89 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | for(e=0; e<(int)p->num_inherits; e++)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
inherit=p->inherits[e];
|
8c8337 | 1998-04-16 | Fredrik Hübinette (Hubbe) | | add_ref(inherit.prog);
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | inherit.identifier_level += Pike_compiler->new_program->num_identifier_references;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | inherit.storage_offset += storage_offset;
inherit.inherit_level ++;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!e)
{
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | if(parent)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
9e5238 | 1998-03-01 | Fredrik Hübinette (Hubbe) | | if(parent->next == parent)
{
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #if 0
|
9e5238 | 1998-03-01 | Fredrik Hübinette (Hubbe) | | struct object *o;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | inherit.parent_offset=0;
for(o=Pike_compiler->fake_object;o!=parent;o=o->parent)
|
9e5238 | 1998-03-01 | Fredrik Hübinette (Hubbe) | | {
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
5aad93 | 2002-08-15 | Marcus Comstedt | | if(!o) Pike_fatal("low_inherit with odd Pike_compiler->fake_object as parent!\n");
|
9e5238 | 1998-03-01 | Fredrik Hübinette (Hubbe) | | #endif
inherit.parent_offset++;
}
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #else
struct program_state *state=Pike_compiler;
inherit.parent_offset=0;
for(;state->fake_object!=parent;state=state->previous)
{
#ifdef PIKE_DEBUG
if(!state->fake_object)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("low_inherit with odd Pike_compiler->fake_object as parent!\n");
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #endif
inherit.parent_offset++;
|