Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
Printer:-AddLibrary - declare that library is used by generated code
Calling Sequence
Printer:-AddLibrary(libraryname)
Parameters
Printer
-
Printer module
libraryname
string; name of library
Description
When called during the printing of intermediate code, the AddLibrary command declares that the library libraryname is used by the generated code.
Many programming languages rely on external archives or libraries to supply functions for specialized tasks. Several CodeGeneration translators produce code that relies on such libraries.
To enable the printing of these inclusion statements in your custom translator, call AddLibrary from within the handler procedure in which the code using this library is printed.
Examples
Define an extension of C that uses custom functions from some library custom_lib addition, negation, multiplication, and inversion.
LanguageDefinition[Define]("AddLibraryExample", extend="C", AddPrintHandler( Names:-Inverse = proc(x) Printer:-Print( "custom_inv(", x, ")"); Printer:-AddLibrary( "custom_lib"); end proc, Names:-Negation = proc(x) Printer:-Print( "custom_neg(", x, ")"); Printer:-AddLibrary( "custom_lib"); end proc, Names:-Product = proc() Printer:-Print( "custom_mult(" ); Printer:-PrintDelimitedList( [args], ", "); Printer:-Print(")"); Printer:-AddLibrary( "custom_lib"); end proc, Names:-Sum = proc() Printer:-Print( "custom_add(" ); Printer:-PrintDelimitedList( [args], ", "); Printer:-Print(")"); Printer:-AddLibrary( "custom_lib"); end proc ) );
Observe that in both cases the custom functions are printed instead of the usual binary operators +,-,*,/, and that in the second case custom_lib is explicitly included.
cg = custom_add(custom_mult(3, x), custom_neg(y));
p := proc(x,y) local z; z := (sin(x)*y+1)*Pi; printf("%f", z); end proc:
void p (double x, double y) { double z; z = custom_mult(custom_add(custom_mult(sin(x), y), 0.1e1), 0.3141592654e1); printf("%f", z); }
See Also
AddFunction, GetIncludes, Printer
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com