2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009-2010 - DIGITEO - Bruno JOFRET
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
21 #include "context.hxx"
23 #include "callable.hxx"
29 class EXTERN_AST Macro : public Callable
33 m_Nargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargin"))),
34 m_Nargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"nargout"))),
35 m_Varargin(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargin"))),
36 m_Varargout(symbol::Context::getInstance()->getOrCreate(symbol::Symbol(L"varargout")))
40 Macro(const std::wstring& _stName, std::list<symbol::Variable*> &_inputArgs, std::list<symbol::Variable*> &_outputArgs, ast::SeqExp &_body, const std::wstring& _stModule);
43 // FIXME : Should not return NULL;
44 Macro* clone() override;
46 inline ScilabType getType(void) override
50 inline ScilabId getId(void) override
54 bool isMacro() override
59 void whoAmI() override;
61 bool toString(std::wostringstream& ostr) override;
63 Callable::ReturnValue call(typed_list &in, optional_list &opt, int _iRetCount, typed_list &out) override;
65 inline void cleanCall(symbol::Context * pContext, int oldPromptMode);
67 ast::SeqExp* getBody();
69 bool getMemory(long long* _piSize, long long* _piSizePlusType) override;
71 /* return type as string ( double, int, cell, list, ... )*/
72 virtual std::wstring getTypeStr() const override
76 /* return type as short string ( s, i, ce, l, ... )*/
77 virtual std::wstring getShortTypeStr() const override
82 const std::wstring& getFileName() const
87 void setFileName(const std::wstring& _fileName)
92 std::list<symbol::Variable*>* getInputs();
93 std::list<symbol::Variable*>* getOutputs();
95 virtual int getNbInputArgument(void) override;
96 virtual int getNbOutputArgument(void) override;
98 bool operator==(const InternalType& it) override;
100 void add_submacro(const symbol::Symbol& s, Macro* macro);
102 inline const std::map<symbol::Variable*, Macro*> & getSubMacros() const
107 inline const std::map<symbol::Variable*, Macro*> & getSubMacros()
113 std::list<symbol::Variable*>* m_inputArgs;
114 std::list<symbol::Variable*>* m_outputArgs;
117 symbol::Variable* m_Nargin;
118 symbol::Variable* m_Nargout;
119 symbol::Variable* m_Varargin;
120 symbol::Variable* m_Varargout;
122 Double* m_pDblArgOut;
123 std::map<symbol::Variable*, Macro*> m_submacro;
124 std::wstring m_stPath;
129 #endif /* !__MACRO_HXX__ */