/* %Z%%M% %I% %E% */

/*
 * Copyright (c) 1990, 1991, 1995 by Wayne C. Gramlich.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * for any purpose is hereby granted without fee provided that the above
 * copyright notice and this permission are retained.  The author makes
 * no representations about the suitability of this software for any purpose.
 * It is provided "as is" without express or implied warranty.
 */

/* This procedure contains the data structures definitions for statements: */

#ifndef STATEMENT_DEFS_H
#define STATEMENT_DEFS_H

#ifndef STATEMENT_EXPORTS_H
#include "statement_exports.h"
#endif

struct Breakpoint_struct {
	int		number;		/* Breakpoint number in routine */
	int		line_number;	/* Line number in file */
};

struct Statement_case_struct {
	Vec(Exp)	exps;		/* Case expression list */
	Str		comment;	/* Comment at end of case */
	int		position;	/* Postion of case statement */
	Vec(Statement)	statements;	/* Statement list */
};

struct Statement_cond_struct {
	Breakpoint	breakpoint;	/* Breakpoint */
	Vec(Call)	calls;		/* Preceeding calls */
	Str		comment;	/* Comment at end of expression */
	Exp		exp;		/* == (Exp)0 for else */
	int		position;	/* File position for expression */
	Vec(Statement)	statements;	/* Statements */
};

struct Statement_extract_struct {
	Vec(Statement_tag) tags;	/* Tag list */
	Exp		exp;		/* Expression to right of := */
	Str		var_name;	/* Variable name */
	Type_ref	var_type_ref;	/* Variable type reference */
};

struct Statement_initialize_struct {
	Str		comment;	/* Comment at end of expression */
	Exp		exp;		/* Expression to right of assign
					 * or (Exp)0 if there is none */
	Str		var_name;	/* Variable name assigned to */
	Type_ref	var_type_ref;	/* Type reference of variable */
	Vec(Statement)	statements;	/* Nested statements */
};

struct Statement_loop_struct {
	int		in_switch;	/* 1 => switch is active on stack */
	int		is_inner_most;	/* 1 => loop is innermost loop */
	Str		name;		/* Loop label name */
	int		need_break;	/* 1 => need a break label */
	int		need_continue;	/* 1 => need a continuation label */
	int		number;		/* Number for unnamed loops (or 0 */
	Vec(Statement)	statements;	/* Loop statements */
};

struct Statement_label_struct {
	Statement_loop	loop;		/* Associated loop object */
	Str		name;		/* Label name */
	int		use_goto;	/* Use a goto statement */
};

struct Statement_tag_struct {
	Str		var_name;	/* (Str)0 => default */
	Type_ref	var_type_ref;	/* (Type_ref)0 => default */
	Vec(Str)	tag_names;	/* Tag name list; empty=>default */
	Vec(Statement)	statements;	/* List of statements */
	int		position;	/* Position in file */
	Str		comment;	/* Comment at end-of-line */
};

struct Statement_switch_struct {
	Exp		exp;		/* Switch expression */
	Vec(Statement_Case) cases;	/* Case statements */
};

union Statement_value_union {
	Exp			exp;	/* until, while */
	Vec(Exp)		exps;	/* return, yield */
	Statement_extract	extract;/* extract */
	Vec(Statement_cond)	xif;	/* if */
	Statement_initialize	initialize; /* init */
	Statement_label		label;	/* break continue */
	Statement_loop		loop;	/* loop */
	int			none;	/* comment */
	Statement_switch	xswitch;/* switch */
};

struct Statement_struct {
	Breakpoint	breakpoint;	/* Any associated breakpoint */
	Vec(Call)	calls;		/* Preceeding calls */
	Str		comment;	/* Statement comment */
	Statement_kind	kind;		/* Kind of statement */
	int		position;	/* Position of statement in file */
	Statement_value	value;		/* Value of statement */
};

#endif /* STATEMENT_DEFS_H */
