get name of current enclosing procedure or module - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Code Generation Package : Language Definition : Printer : CodeGeneration/LanguageDefinition/Printer/GetScopeName

Printer:-GetScopeName - get name of current enclosing procedure or module

Calling Sequence

Printer:-GetScopeName()

Parameters

Printer

-

Printer module

Description

• 

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.

Examples

Define a sample language GetScopeNameExample, using GetScopeName to obtain the name of a procedure during the printing phase.

withCodeGeneration:

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:

Translatep,language=GetScopeNameExample

procedure p (integer x, double y) : integer

  Return(2 * x);

end procedure;

See Also

GetExpressionType, GetScopeStructure, Printer


Download Help Document

Copyright © MathResources Inc. All Rights Reserved.

www.mathresources.com

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam