1 (* m2statement.def definition module for m2statement.cc.
3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE FOR "C" m2statement ;
25 FROM SYSTEM IMPORT ADDRESS ;
26 FROM m2tree IMPORT Tree ;
27 FROM m2linemap IMPORT location_t ;
28 FROM m2expr IMPORT BuildUnarySetFunction ;
32 DoJump - jump to the appropriate label depending whether
33 result of the expression is TRUE or FALSE.
36 PROCEDURE DoJump (location: location_t; exp: Tree; falselabel: ADDRESS; truelabel: ADDRESS) ;
40 BuildStartFunctionCode - generate function entry code.
43 PROCEDURE BuildStartFunctionCode (location: location_t; fndecl: Tree; isexported: BOOLEAN; isinline: BOOLEAN) ;
47 BuildEndFunctionCode - generates the function epilogue.
50 PROCEDURE BuildEndFunctionCode (location: location_t; fndecl: Tree; nested: BOOLEAN) ;
54 BuildReturnValueCode - generates the code associated with: RETURN( value )
57 PROCEDURE BuildReturnValueCode (location: location_t; fndecl: Tree; value: Tree) ;
61 BuildPushFunctionContext - pushes the current function context.
62 Maps onto push_function_context in ../function.c
65 PROCEDURE BuildPushFunctionContext ;
69 BuildPopFunctionContext - pops the current function context.
70 Maps onto pop_function_context in ../function.c
73 PROCEDURE BuildPopFunctionContext ;
77 BuildAssignmentTree - builds the assignment of, des, and, expr.
81 PROCEDURE BuildAssignmentTree (location: location_t; des, expr: Tree) : Tree ;
85 BuildAssignmentStatement builds the assignment of, des, and, expr.
88 PROCEDURE BuildAssignmentStatement (location: location_t; des, expr: Tree) ;
92 BuildGoto - builds a goto operation.
95 PROCEDURE BuildGoto (location: location_t; name: ADDRESS) ;
99 DeclareLabel - create a label, name.
102 PROCEDURE DeclareLabel (location: location_t; name: ADDRESS) ;
106 BuildIfThenDoEnd - returns a tree which will only execute
107 statement, s, if, condition, is true.
110 PROCEDURE BuildIfThenDoEnd (condition: Tree; then_block: Tree) : Tree ;
114 BuildIfThenElseEnd - returns a tree which will execute
115 then_block or else_block depending upon,
119 PROCEDURE BuildIfThenElseEnd (condition: Tree; then_block: Tree; else_block: Tree) : Tree ;
123 BuildParam - build a list of parameters, ready for a subsequent procedure call.
126 PROCEDURE BuildParam (location: location_t; param: Tree) ;
130 BuildFunctionCallTree - creates a procedure function call from
131 a procedure and parameter list and the
132 return type, rettype. No tree is returned
133 as the tree is held in the last_function
134 global variable. It is expected the
135 BuildFunctValue is to be called after
136 a call to BuildFunctionCallTree.
139 PROCEDURE BuildFunctionCallTree (location: location_t; procedure: Tree; rettype: Tree) ;
143 BuildProcedureCallTree - creates a procedure call from a procedure and
144 parameter list and the return type, rettype.
147 PROCEDURE BuildProcedureCallTree (location: location_t; procedure: Tree; rettype: Tree) : Tree ;
151 BuildIndirectProcedureCallTree - creates a procedure call from a procedure and
152 parameter list and the return type, rettype.
155 PROCEDURE BuildIndirectProcedureCallTree (location: location_t; procedure: Tree; rettype: Tree) : Tree ;
159 BuildFunctValue - generates code for value := last_function(foobar);
162 PROCEDURE BuildFunctValue (location: location_t; value: Tree) : Tree ;
166 BuildCall2 - builds a tree representing: function(arg1, arg2).
169 PROCEDURE BuildCall2 (location: location_t;
170 function, rettype, arg1, arg2: Tree) : Tree ;
174 BuildCall3 - builds a tree representing: function(arg1, arg2, arg3).
177 PROCEDURE BuildCall3 (location: location_t;
178 function, rettype, arg1, arg2, arg3: Tree) : Tree ;
182 SetLastFunction - set the last_function to, t.
185 PROCEDURE SetLastFunction (t: Tree) ;
189 GetLastFunction - returns, last_function.
192 PROCEDURE GetLastFunction () : Tree ;
196 GetParamTree - return parameter, i.
199 PROCEDURE GetParamTree (call: Tree; i: CARDINAL) : Tree ;
203 BuildTryFinally - returns a TRY_FINALL_EXPR with the call and cleanups
207 PROCEDURE BuildTryFinally (location: location_t; call: Tree; cleanups: Tree) : Tree ;
211 BuildCleanUp - return a CLEANUP_POINT_EXPR which will clobber, param.
214 PROCEDURE BuildCleanUp (param: Tree) : Tree ;
218 BuildAsm - generates an inline assembler instruction.
221 PROCEDURE BuildAsm (location: location_t; instr: Tree;
222 isVolatile: BOOLEAN; isSimple: BOOLEAN;
223 inputs: Tree; outputs: Tree; trash: Tree; labels: Tree) ;
227 BuildUnaryForeachWordDo - provides the large set operators.
228 Each word (or less) of the set can be
230 This procedure iterates over each word
231 of the large set invoking the unop.
234 PROCEDURE BuildUnaryForeachWordDo (location: location_t; type: Tree; op1: Tree; op2: Tree;
235 unop: BuildUnarySetFunction;
236 is_op1lvalue, is_op2lvalue, is_op1const, is_op2const: BOOLEAN) ;
240 BuildExcludeVarConst - builds the EXCL(op1, 1<<op2) operation for a small sets. Large
241 sets call this routine to exclude the bit in the particular word.
245 PROCEDURE BuildExcludeVarConst (location: location_t; type: Tree; op1: Tree; op2: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ;
249 BuildExcludeVarVar - builds the EXCL(varset, 1<<varel) operation for a small and large sets.
253 PROCEDURE BuildExcludeVarVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree) ;
257 BuildIncludeVarConst - builds the INCL(op1, 1<<op2) operation for a small sets. Large
258 sets call this routine to include the bit in the particular word.
262 PROCEDURE BuildIncludeVarConst (location: location_t; type: Tree; op1: Tree; op2: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ;
266 BuildIncludeVarVar - builds the INCL(varset, 1<<varel) operation for a small and large sets.
270 PROCEDURE BuildIncludeVarVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree) ;
274 BuildStart - creates a module initialization function. We make
275 this function public if it is not an inner module.
276 The linker will create a call list for all linked
277 modules which determines the initialization
278 sequence for all modules.
281 PROCEDURE BuildStart (location: location_t; name: ADDRESS; inner_module: BOOLEAN) : Tree ;
285 BuildEnd - complete the initialisation function for this module.
288 PROCEDURE BuildEnd (location: location_t; fndecl: Tree; nested: BOOLEAN) ;
292 BuildCallInner - call the inner module function. It has no parameters and no return value.
295 PROCEDURE BuildCallInner (location: location_t; fndecl: Tree) ;
299 SetBeginLocation - sets the begin location for the function to obtain good debugging info.
302 PROCEDURE SetBeginLocation (location: location_t) ;
306 SetEndLocation - sets the end location for the function to obtain good debugging info.
309 PROCEDURE SetEndLocation (location: location_t) ;