Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - English


macr2tree

provides the internal code of a compiled Scilab function

Syntax

p = macr2tree(function)

Arguments

function

handle of a Scilab macro (not its name as a string)

p

List of type program with the fields p.name, p.nblines, p.inputs, p.outputs, and p.statements. The 3 last ones are nested lists describing the internal code of the function. The output of macr2tree is usually used to feed tree2code(..).

Description

This primitive converts a compiled Scilab function into a tree (nested tlists) which codes the internal representation of the function. For use with tree2code.

Examples

prog = macr2tree(log2);   // Note that the input is log2, not "log2"
typeof(prog)
fieldnames(prog)'
prog.name
deftxt = tree2code(prog, %T);
printf("%s\n", deftxt);
--> typeof(prog)
 ans  =
 program

--> fieldnames(prog)'
 ans  =
!name  outputs  inputs  statements  nblines  !

--> prog.name
 ans  =
 log2

--> deftxt = tree2code(prog, %T);

--> printf("%s\n", deftxt);
function [f,e] = log2(x)
  [lhs,rhs] = argn(0)
  if rhs <>1 then
    msg = gettext("%s: Wrong number of input argument(s): %d expected.\n")
    error(msprintf(msg, "log2", 1))
  end
  if argn(1)==1 then
    f = log(x)/log(2)
  else
    [f,e] = frexp(x)
  end
endfunction

See also

  • tree2code — generates the text definition of a Scilab function from its internal code
  • macrovar — variables of function
  • functions — Scilab procedures and Scilab objects
Report an issue
<< getd Advanced functions macro >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Mar 27 11:52:51 GMT 2023