2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #include "AnalysisVisitor.hxx"
14 #include "analyzers/ArgnAnalyzer.hxx"
20 bool ArgnAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
27 TIType type(visitor.getGVN(), TIType::DOUBLE);
28 FunctionBlock * fblock = visitor.getDM().topFunction();
33 Result & res = e.getDecorator().setResult(type);
34 res.getConstant() = new types::Double(0);
35 e.getDecorator().setCall(L"argn");
36 visitor.setResult(res);
45 LHS, RHS, LHSRHS, DUNNO
47 const ast::exps_t args = e.getArgs();
64 ast::Exp * first = args.front();
65 if (first && first->isDoubleExp())
67 const double arg1 = static_cast<ast::DoubleExp *>(first)->getValue();
107 const int64_t val = kind == LHS ? fblock->getLHS() : fblock->getRHS();
108 Result & res = e.getDecorator().setResult(type);
109 res.getConstant() = visitor.getGVN().getValue(val);
110 e.getDecorator().setCall(L"argn");
111 visitor.setResult(res);
116 std::vector<Result> & mlhs = visitor.getLHSContainer();
120 const int64_t flhs = fblock->getLHS();
121 const int64_t frhs = fblock->getRHS();
122 mlhs.emplace_back(type);
123 mlhs.back().getConstant() = visitor.getGVN().getValue(flhs);
124 mlhs.emplace_back(type);
125 mlhs.back().getConstant() = visitor.getGVN().getValue(frhs);
127 e.getDecorator().setCall(L"argn");