Printer
GetScopeName
get name of current enclosing procedure or module
Calling Sequence
Parameters
Description
Examples
Printer:-GetScopeName()
-
Printer module
When called during the printing of intermediate code, the GetScopeName command returns the Name or GeneratedName corresponding to the name of the innermost enclosing procedure or module. For example, during the printing of a procedure body, GetScopeName returns the procedure's name.
If the enclosing scope does not have a name associated with it (for example, when the input is a single expression or a computation sequence) then NULL is returned.
Define a sample language GetScopeNameExample, using GetScopeName to obtain the name of a procedure during the printing phase.
with⁡CodeGeneration:
LanguageDefinition[Define]( "GetScopeNameExample", SetLanguageAttribute( "Procedure_Begin" = proc(rettype, paramseq) local procedure_name; procedure_name := Printer:-GetScopeName(); ("procedure ", procedure_name, " ", paramseq, " : ", rettype,"\n") end proc, "Procedure_End" = proc(rettype) ("end procedure;\n"); end proc, "Procedure_ParametersInBody" = false ) ):
p := proc(x,y) 2*x end proc:
Translate⁡p,language=GetScopeNameExample
procedure p (integer x, double y) : integer Return(2 * x); end procedure;
See Also
GetExpressionType
GetScopeStructure
Download Help Document