pike.git/
src/
language.yacc
Branch:
Tag:
Non-build tags
All tags
No tags
2017-12-11
2017-12-11 18:05:19 by Henrik Grubbström (Grubba) <grubba@grubba.org>
bdfe4eadf595e0fceedfb4cc85bf6266720a7498 (
59
lines) (+
32
/-
27
)
[
Show
|
Annotate
]
Branch:
master
Compiler: Add symbolic constants COMPILER_PASS_*.
This is in preparation for adding more passes.
476:
inheritance: modifiers TOK_INHERIT inherit_ref optional_rename_inherit ';' {
-
if (($1 & ID_EXTERN) && (Pike_compiler->compiler_pass ==
1
)) {
+
if (($1 & ID_EXTERN) &&
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
)) {
yywarning("Extern declared inherit."); } if($3)
574:
define_alias($1->u.sval.u.string, n->type, Pike_compiler->current_modifiers & ~ID_EXTERN, depth, id);
-
} else if (Pike_compiler->compiler_pass ==
1
) {
+
} else if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
yyerror("Invalid extern declared constant."); add_constant($1->u.sval.u.string, &svalue_undefined, Pike_compiler->current_modifiers & ~ID_EXTERN); } } else { if(!is_const($3)) {
-
if (Pike_compiler->compiler_pass ==
2
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) {
yyerror("Constant definition is not constant."); } add_constant($1->u.sval.u.string, 0,
806:
struct pike_type *s=compiler_pop_type(); int i = isidentifier($5->u.sval.u.string);
-
if (Pike_compiler->compiler_pass !=
1
) {
+
if (Pike_compiler->compiler_pass !=
COMPILER_PASS_FIRST
) {
if (i < 0) { my_yyerror("Identifier %S lost after first pass.", $5->u.sval.u.string);
818:
}
-
/* if(Pike_compiler->compiler_pass==
1
) */
+
/* if(Pike_compiler->compiler_pass
==
COMPILER_PASS_FIRST
) */
{ /* FIXME: * set current_function_number for local functions as well
850:
c->lex.current_file = $5->current_file; c->lex.current_line = $5->line_number;
-
if (($1 & ID_EXTERN) && (Pike_compiler->compiler_pass ==
1
)) {
+
if (($1 & ID_EXTERN) &&
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
)) {
yywarning("Extern declared function definition."); }
862:
{ my_yyerror("Missing name for argument %d.", e - $<number>8); } else {
-
if (Pike_compiler->compiler_pass ==
2
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) {
/* FIXME: Should probably use some other flag. */ if ((runtime_options & RUNTIME_CHECK_TYPES) && (Pike_compiler->compiler_frame->variable[e].type !=
913:
i = ID_FROM_INT(Pike_compiler->new_program, f); i->opt_flags = Pike_compiler->compiler_frame->opt_flags;
-
if (Pike_compiler->compiler_pass ==
2
&&
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
&&
Pike_compiler->compiler_frame->current_return_type->type == PIKE_T_AUTO) { /* Change "auto" return type to actual return type. */
955:
Pike_interpreter.recoveries->stack_pointer)) Pike_fatal("Stack error (underflow)\n");
-
if((Pike_compiler->compiler_pass ==
1
) &&
+
if((Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) &&
(f != Pike_compiler->compiler_frame->current_function_number)) { fprintf(stderr, "define_function()/do_opt_code() failed for symbol %s\n", $5->u.sval.u.string->str);
1118:
| TOK_STATIC { $$ = ID_PROTECTED; if( !(THIS_COMPILATION->lex.pragmas & ID_NO_DEPRECATION_WARNINGS) &&
-
!TEST_COMPAT(7, 8) && Pike_compiler->compiler_pass==
1
)
+
!TEST_COMPAT(7, 8) &&
+
(
Pike_compiler->compiler_pass
==
COMPILER_PASS_FIRST
)
)
yywarning("Keyword static is deprecated in favour of 'protected'."); } | TOK_EXTERN { $$ = ID_EXTERN; }
1520:
/* function_type_list ends with a comma, or is empty. * FIXME: Should this be a syntax error or not? */
-
if (Pike_compiler->compiler_pass ==
1
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
) {
yyerror("Missing type before ... ."); } push_type(T_MIXED);
1620:
} type=compiler_pop_type(); if ((Pike_compiler->current_modifiers & ID_EXTERN) &&
-
(Pike_compiler->compiler_pass ==
1
)) {
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
)) {
yywarning("Extern declared variable has initializer."); } $<number>$=define_variable($1->u.sval.u.string, type,
1629:
} expr0 {
-
if ((Pike_compiler->compiler_pass ==
2
) &&
+
if ((Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) &&
!TEST_COMPAT(7, 8) && ($4) && ($4->token == F_CONSTANT) && !Pike_compiler->num_parse_error) { /* Check if it is zero, in which case we can throw it away.
1729:
pop_stack_mark(); update_current_type(); copy_pike_type(type, Pike_compiler->compiler_frame->current_type);
-
if( type->type == PIKE_T_AUTO && Pike_compiler->compiler_pass ==
2
)
+
if( type->type == PIKE_T_AUTO &&
+
Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
)
{ free_type( type ); fix_type_field( $4 );
1818:
while (Pike_compiler != $<ptr>5) { struct program *p; /* fprintf(stderr, "Compiler context out of sync. Attempting to recover...\n"); */
-
if(Pike_compiler->compiler_pass =
=
1
)
+
if(Pike_compiler->compiler_pass
!
=
COMPILER_PASS_LAST
)
p = end_first_pass(0); else p=end_first_pass(1);
2618:
} }
-
if(Pike_compiler->compiler_pass =
=
1
)
+
if(Pike_compiler->compiler_pass
!
=
COMPILER_PASS_LAST
)
p=end_first_pass(0); else p=end_first_pass(1);
2874:
} }
-
if(Pike_compiler->compiler_pass =
=
1
)
+
if(Pike_compiler->compiler_pass
!
=
COMPILER_PASS_LAST
)
p=end_first_pass(0); else p=end_first_pass(1);
2932:
if(!is_const($2)) {
-
if(Pike_compiler->compiler_pass==
2
)
+
if(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)
yyerror("Enum definition is not constant."); push_int(0); } else {
2996:
enum: TOK_ENUM { if ((Pike_compiler->current_modifiers & ID_EXTERN) &&
-
(Pike_compiler->compiler_pass ==
1
)) {
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
)) {
yywarning("Extern declared enum."); }
3030:
struct pike_type *t = compiler_pop_type(); if ((Pike_compiler->current_modifiers & ID_EXTERN) &&
-
(Pike_compiler->compiler_pass ==
1
)) {
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_FIRST
)) {
yywarning("Extern declared typedef."); }
3122:
{ /* Fix AUTO type. */ struct pike_type *ind=NULL, *val=NULL;
-
if(Pike_compiler->compiler_pass ==
2
)
+
if(Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
)
{ fix_type_field( $6 ); fix_type_field( $7 );
3556:
debug_malloc_touch($5); $5=mknode(F_COMMA_EXPR,$5,mknode(F_RETURN,mkintnode(0),0));
-
if (Pike_compiler->compiler_pass =
=
2
) {
+
if (Pike_compiler->compiler_pass
!
=
COMPILER_PASS_FIRST
) {
/* Doing this in pass 1 might induce too strict checks on types * in cases where we got placeholders. */ type=find_return_type($5);
4076:
!($$ = program_magic_identifier (Pike_compiler, 0, -1, Pike_compiler->last_identifier, 0))) { if((Pike_compiler->flags & COMPILATION_FORCE_RESOLVE) ||
-
(Pike_compiler->compiler_pass==
2
)) {
+
(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)) {
my_yyerror("Undefined identifier %S.", Pike_compiler->last_identifier); /* FIXME: Add this identifier as a constant in the current program to
4167:
Pike_compiler->last_identifier); if (!$$) { if ((Pike_compiler->flags & COMPILATION_FORCE_RESOLVE) ||
-
(Pike_compiler->compiler_pass ==
2
)) {
+
(Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
)) {
if (($1 >= 0) && inherit_state->new_program->inherits[$1].name) { my_yyerror("Undefined identifier %S::%S.", inherit_state->new_program->inherits[$1].name,
4197:
Pike_compiler->last_identifier); if(!$$) {
-
if (Pike_compiler->compiler_pass ==
2
) {
+
if (Pike_compiler->compiler_pass ==
COMPILER_PASS_LAST
) {
my_yyerror("Undefined identifier ::%S.", $2->u.sval.u.string); } $$=mkintnode(0);
4692:
int var = frame->current_number_of_locals; if (pike_types_le(type, void_type_string)) {
-
if (Pike_compiler->compiler_pass
!
=
1
) {
+
if (Pike_compiler->compiler_pass =
=
COMPILER_PASS_LAST
) {
yywarning("Declaring local variable %S with type void " "(converted to type zero).", str); }
4952:
if (!res && !(res = resolve_identifier(identifier))) { if((Pike_compiler->flags & COMPILATION_FORCE_RESOLVE) ||
-
(Pike_compiler->compiler_pass==
2
)) {
+
(Pike_compiler->compiler_pass
==
COMPILER_PASS_LAST
)) {
my_yyerror("Undefined identifier %d.%d::%S.", major, minor, identifier); }else{