Skip to content
Snippets Groups Projects
Commit b9188f2c authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Now creates arg checking code when compiling with d_flag.

Rev: src/language.yacc:1.142
parent 2f965a3b
No related branches found
No related tags found
No related merge requests found
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
/* This is the grammar definition of Pike. */ /* This is the grammar definition of Pike. */
#include "global.h" #include "global.h"
RCSID("$Id: language.yacc,v 1.141 1999/12/09 23:24:58 grubba Exp $"); RCSID("$Id: language.yacc,v 1.142 1999/12/13 00:22:49 grubba Exp $");
#ifdef HAVE_MEMORY_H #ifdef HAVE_MEMORY_H
#include <memory.h> #include <memory.h>
#endif #endif
...@@ -202,6 +202,7 @@ RCSID("$Id: language.yacc,v 1.141 1999/12/09 23:24:58 grubba Exp $"); ...@@ -202,6 +202,7 @@ RCSID("$Id: language.yacc,v 1.141 1999/12/09 23:24:58 grubba Exp $");
#include "error.h" #include "error.h"
#include "docode.h" #include "docode.h"
#include "machine.h" #include "machine.h"
#include "main.h"
#define YYMAXDEPTH 1000 #define YYMAXDEPTH 1000
...@@ -680,15 +681,43 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER ...@@ -680,15 +681,43 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER
if($10) if($10)
{ {
int f; int f;
node *check_args = NULL;
for(e=0; e<$7; e++) for(e=0; e<$7; e++)
{ {
if(!compiler_frame->variable[e].name || if(!compiler_frame->variable[e].name ||
!compiler_frame->variable[e].name->len) !compiler_frame->variable[e].name->len)
{ {
my_yyerror("Missing name for argument %d.",e); my_yyerror("Missing name for argument %d.",e);
} else {
/* FIXME: Should probably use some other flag. */
if (d_flag && (compiler_pass == 2) &&
(compiler_frame->variable[e].type != mixed_type_string)) {
node *local_node;
/* fprintf(stderr, "Creating soft cast node for local #%d\n", e);*/
local_node = mklocalnode(e, 0);
/* The following is needed to go around the optimization in
* mksoftcastnode().
*/
free_string(local_node->type);
copy_shared_string(local_node->type, mixed_type_string);
check_args =
mknode(F_COMMA_EXPR, check_args,
mksoftcastnode(compiler_frame->variable[e].type,
local_node));
}
} }
} }
if (check_args) {
/* Prepend the arg checking code. */
$10 = mknode(F_COMMA_EXPR, mknode(F_POP_VALUE, check_args, NULL), $10);
}
f=dooptcode(check_node_hash($4)->u.sval.u.string, check_node_hash($10), f=dooptcode(check_node_hash($4)->u.sval.u.string, check_node_hash($10),
check_node_hash($<n>9)->u.sval.u.string, $1); check_node_hash($<n>9)->u.sval.u.string, $1);
#ifdef PIKE_DEBUG #ifdef PIKE_DEBUG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment