blob: 1860379ef239b11869bb9b24a508b6a7afbf515c [file] [log] [blame]
(* m2block.def definition module for m2block.cc.
Copyright (C) 2011-2025 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
This file is part of GNU Modula-2.
GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Modula-2; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. *)
DEFINITION MODULE FOR "C" m2block ;
FROM gcctypes IMPORT location_t, tree ;
FROM CDataTypes IMPORT CharStar ;
(*
init - initialise the data structures in this module.
*)
PROCEDURE init ;
(*
toplevel - return TRUE if we are in the global scope.
*)
PROCEDURE toplevel () : BOOLEAN ;
(*
global_constant - t is a constant, we keep a chain of all constants
in the global binding level.
*)
PROCEDURE global_constant (t: tree) : tree ;
(*
RememberInitModuleFunction - records tree, t, in the global binding level.
So that it will not be garbage collected.
In theory the inner modules could be placed
inside the current_binding_level I suspect.
*)
PROCEDURE RememberInitModuleFunction (t: tree) : tree ;
(*
DumpGlobalConstants - displays all global constants and checks none are
poisoned.
*)
PROCEDURE DumpGlobalConstants () : tree ;
(*
RememberConstant - adds a tree, t, onto the list of constants to be marked
whenever the ggc re-marks all used storage. Constants
live throughout the whole compilation - and they
can be used by many different functions if necessary.
*)
PROCEDURE RememberConstant (t: tree) : tree ;
(*
RememberType - remember the type, t, in the ggc marked list.
*)
PROCEDURE RememberType (t: tree) : tree ;
(*
pushDecl - pushes a declaration onto the current binding level.
*)
PROCEDURE pushDecl (decl: tree) : tree ;
(*
popGlobalScope - pops the current binding level, it expects this binding level
to be the global binding level.
*)
PROCEDURE popGlobalScope ;
(*
pushGlobalScope - push the global scope onto the binding level stack.
There can only ever be one instance of the global binding
level on the stack.
*)
PROCEDURE pushGlobalScope ;
(*
popFunctionScope - pops a binding level, returning the function associated with the
binding level.
*)
PROCEDURE popFunctionScope () : tree ;
(*
pushFunctionScope - push a binding level.
*)
PROCEDURE pushFunctionScope (fndecl: tree) ;
(*
finishFunctionCode - adds cur_stmt_list to fndecl. The current binding level
is then able to be destroyed by a call to popFunctionScope.
The cur_stmt_list is appended to the STATEMENT_LIST.
*)
PROCEDURE finishFunctionCode (fndecl: tree) ;
(*
finishFunctionDecl - removes declarations from the current binding level and places
them inside fndecl. The current binding level is then able to
be destroyed by a call to popFunctionScope.
The extra tree nodes associated with fndecl will be created
such as BIND_EXPR, BLOCK and the initial STATEMENT_LIST
containing the DECL_EXPR is also created.
*)
PROCEDURE finishFunctionDecl (location: location_t; fndecl: tree) ;
(*
getLabel - return the label, name, or create a label, name
in the current scope.
*)
PROCEDURE getLabel (location: location_t; name: CharStar) : tree ;
(*
GetErrorNode - returns the gcc error_mark_node.
*)
PROCEDURE GetErrorNode () : tree ;
(*
includeDecl - pushes a declaration onto the current binding level providing
it is not already present.
*)
PROCEDURE includeDecl (decl: tree) ;
(*
GetGlobals - returns a list of global variables, functions, constants.
*)
PROCEDURE GetGlobals () : tree ;
(*
GetGlobalContext - returns the global context tree.
*)
PROCEDURE GetGlobalContext () : tree ;
(*
begin_statement_list - starts a tree statement. It pushes the
statement list and returns the list node.
*)
PROCEDURE begin_statement_list () : tree ;
(*
push_statement_list - pushes the statement list, t, onto the
current binding level.
*)
PROCEDURE push_statement_list (t: tree) : tree ;
(*
pop_statement_list - pops and returns a statement list from the
current binding level.
*)
PROCEDURE pop_statement_list () : tree ;
(*
addStmtNote - remember this location represents the start of a Modula-2
statement. It is flushed if another different location is
generated or another tree is given to add_stmt.
*)
PROCEDURE addStmtNote (location: location_t) ;
(*
removeStmtNote - removes any pending stmt note.
*)
PROCEDURE removeStmtNote ;
END m2block.