pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: program.c,v 1.
713
2008/05/31
12
:
15
:
18
grubba Exp $
+
|| $Id: program.c,v 1.
714
2008/05/31
16
:
21
:
30
grubba Exp $
*/ #include "global.h" #include "program.h" #include "object.h" #include "dynamic_buffer.h" #include "pike_types.h" #include "stralloc.h" #include "las.h" #include "lex.h"
pike.git/src/program.c:6312:
} fail: to->type=T_INT; to->subtype=NUMBER_UNDEFINED; to->u.integer=0; return 1; } /*
-
* Line number support routines, now also tells what file we are in
+
* Line number support routines, now also tells what file we are in
.
+
*
+
* FIXME: Consider storing the filenames in strings (like what is now done
+
* for identifiers).
*/ /* program.linenumbers format: * * Filename entry: * 1. char 127 (marker). * 2. small number Filename string length. * 3. char Filename string size shift.
-
* 4. string data (Possibly wide) filename string without null termination.
+
* 4. string data (Possibly wide) filename string without null
+
*
termination.
* Each character is stored in native byte order. * * Line number entry: * 1. small number Index in program.program (pc). * Stored as the difference from the pc in the * closest previous line number entry. The first * stored entry is absolute. * 2. small number Line number. Stored in the same way as the pc. * * Small number: * If -127 < n < 127: * 1. char The number. * Else if -32768 <= n < 32768: * 1. char -127 (marker).
-
* 2. short The number stored in big endian order.
+
* 2. short The
16-bit signed
number stored in big endian order.
* Else: * 1. char -128 (marker).
-
* 2. int The number stored in big endian order.
+
* 2. int The
32-bit signed
number stored in big endian order.
* * Whenever the filename changes, a filename entry followed by a line * number entry is stored. If only the line number changes, a line * number entry is stored. The first stored entry (at pc 0) is the * file and line where the program is defined, if they are known. The * definition line for a top level program is set to 0. */ int get_small_number(char **q) {
pike.git/src/program.c:6849:
o = loc.o; } if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags)) return low_get_line (p->program + id->func.offset, p, linep); return low_get_program_line(o->prog, linep); } *linep = 0; return NULL; }
+
/* Return the file and line where the identifier with reference number
+
* fun was defined.
+
*
+
* Note: Unlike the other get*line() functions, this one does not
+
* add a reference to the returned string.
+
*/
+
PMOD_EXPORT struct pike_string *get_identifier_line(struct program *p,
+
int fun, INT32 *linep)
+
{
+
struct reference *ref = PTR_FROM_INT(p, fun);
+
struct identifier *id = ID_FROM_PTR(p, ref);
+
p = PROG_FROM_PTR(p, ref);
+
if (id->filename_strno < 0) return NULL;
+
if (linep) *linep = id->linenumber;
+
return p->strings[id->filename_strno];
+
}
+
/* Main entry point for compiler messages originating from * C-code. * * Sends the message along to PikeCompiler()->report(). * * NOTE: The format string fmt (and vargs) is only formatted with * string_builder_vsprintf() if the number of extra * Pike stack arguments (args) is zero. */ PMOD_EXPORT void va_yyreport(int severity_level,
pike.git/src/program.c:10530:
if(s == bid->name) continue; /* Skip __INIT */ i = find_shared_string_identifier(bid->name,a); if (i == -1) { continue; /* It's ok... */ } /* Note: Uses weaker check for constant integers. */ if(((bid->run_time_type != PIKE_T_INT) || (ID_FROM_INT(a, i)->run_time_type != PIKE_T_INT)) && !match_types(ID_FROM_INT(a,i)->type, bid->type)) {
+
INT32 aid_line = a_line;
+
INT32 bid_line = b_line;
+
struct pike_string *aid_file = get_identifier_line(a, i, &aid_line);
+
struct pike_string *bid_file = get_identifier_line(b, i, &bid_line);
+
if (!aid_file) aid_file = a_file;
+
if (!bid_file) bid_file = b_file;
ref_push_string(bid->name); ref_push_program(a); ref_push_program(b); yytype_report(severity_level,
-
a
_file,
a
_line, ID_FROM_INT(a, i)->type,
-
b
_file,
b
_line, bid->type, 3,
+
aid
_file,
aid
_line, ID_FROM_INT(a, i)->type,
+
bid
_file,
bid
_line, bid->type, 3,
"Identifier %s in %O is incompatible with the same in %O."); } } free_string(b_file); free_string(a_file); END_CYCLIC(); return; } /* Explains why a does not implement b */
pike.git/src/program.c:10576:
for(e=0;e<b->num_identifier_references;e++) { struct identifier *bid; int i; if (b->identifier_references[e].id_flags & (ID_STATIC|ID_HIDDEN)) continue; /* Skip static & hidden */ bid = ID_FROM_INT(b,e); if(s == bid->name) continue; /* Skip __INIT */ i = find_shared_string_identifier(bid->name,a); if (i == -1) {
+
INT32 bid_line = b_line;
+
struct pike_string *bid_file;
if (b->identifier_references[e].id_flags & (ID_OPTIONAL)) continue; /* It's ok... */
-
+
bid_file = get_identifier_line(b, i, &bid_line);
+
if (!bid_file) bid_file = b_file;
yytype_report(severity_level,
-
b
_file,
b
_line, bid->type,
+
bid
_file,
bid
_line, bid->type,
a_file, a_line, NULL, 0, "Missing identifier %S.", bid->name); continue; } if (!pike_types_le(bid->type, ID_FROM_INT(a, i)->type)) {
-
+
INT32 aid_line = a_line;
+
INT32 bid_line = b_line;
+
struct pike_string *aid_file = get_identifier_line(a, i, &aid_line);
+
struct pike_string *bid_file = get_identifier_line(b, i, &bid_line);
+
if (!aid_file) aid_file = a_file;
+
if (!bid_file) bid_file = b_file;
if(!match_types(ID_FROM_INT(a,i)->type, bid->type)) { yytype_report(severity_level,
-
b
_file,
b
_line, bid->type,
-
a
_file,
a
_line, ID_FROM_INT(a, i)->type,
+
bid
_file,
bid
_line, bid->type,
+
aid
_file,
aid
_line, ID_FROM_INT(a, i)->type,
0, "Type of identifier %S does not match.", bid->name); } else { yytype_report(REPORT_WARNING,
-
NULL
,
0
, bid->type,
-
NULL
,
0
, ID_FROM_INT(a, i)->type,
+
bid_file
,
bid_line
, bid->type,
+
aid_file
,
aid_line
, ID_FROM_INT(a, i)->type,
0, "Type of identifier %S is not strictly compatible.", bid->name); } continue; } } free_string(b_file); free_string(a_file); END_CYCLIC(); }