src/cpp/analysis/Block.cpp \
src/cpp/analysis/Checkers.cpp \
src/cpp/analysis/CompleteMacroSignature.cpp \
+src/cpp/analysis/ConstantValue.cpp \
src/cpp/analysis/ConstraintManager.cpp \
src/cpp/analysis/DiagAnalyzer.cpp \
src/cpp/analysis/FunctionBlock.cpp \
src/cpp/analysis/ArgnAnalyzer.cpp src/cpp/analysis/Block.cpp \
src/cpp/analysis/Checkers.cpp \
src/cpp/analysis/CompleteMacroSignature.cpp \
+ src/cpp/analysis/ConstantValue.cpp \
src/cpp/analysis/ConstraintManager.cpp \
src/cpp/analysis/DiagAnalyzer.cpp \
src/cpp/analysis/FunctionBlock.cpp \
src/cpp/analysis/libsciast_la-Block.lo \
src/cpp/analysis/libsciast_la-Checkers.lo \
src/cpp/analysis/libsciast_la-CompleteMacroSignature.lo \
+ src/cpp/analysis/libsciast_la-ConstantValue.lo \
src/cpp/analysis/libsciast_la-ConstraintManager.lo \
src/cpp/analysis/libsciast_la-DiagAnalyzer.lo \
src/cpp/analysis/libsciast_la-FunctionBlock.lo \
src/cpp/analysis/ArgnAnalyzer.cpp src/cpp/analysis/Block.cpp \
src/cpp/analysis/Checkers.cpp \
src/cpp/analysis/CompleteMacroSignature.cpp \
+ src/cpp/analysis/ConstantValue.cpp \
src/cpp/analysis/ConstraintManager.cpp \
src/cpp/analysis/DiagAnalyzer.cpp \
src/cpp/analysis/FunctionBlock.cpp \
src/cpp/analysis/libsciast_la-CompleteMacroSignature.lo: \
src/cpp/analysis/$(am__dirstamp) \
src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
+src/cpp/analysis/libsciast_la-ConstantValue.lo: \
+ src/cpp/analysis/$(am__dirstamp) \
+ src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
src/cpp/analysis/libsciast_la-ConstraintManager.lo: \
src/cpp/analysis/$(am__dirstamp) \
src/cpp/analysis/$(DEPDIR)/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-Block.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-Checkers.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-CompleteMacroSignature.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstantValue.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstraintManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-DiagAnalyzer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/analysis/$(DEPDIR)/libsciast_la-FunctionBlock.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-CompleteMacroSignature.lo `test -f 'src/cpp/analysis/CompleteMacroSignature.cpp' || echo '$(srcdir)/'`src/cpp/analysis/CompleteMacroSignature.cpp
+src/cpp/analysis/libsciast_la-ConstantValue.lo: src/cpp/analysis/ConstantValue.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-ConstantValue.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstantValue.Tpo -c -o src/cpp/analysis/libsciast_la-ConstantValue.lo `test -f 'src/cpp/analysis/ConstantValue.cpp' || echo '$(srcdir)/'`src/cpp/analysis/ConstantValue.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstantValue.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstantValue.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/analysis/ConstantValue.cpp' object='src/cpp/analysis/libsciast_la-ConstantValue.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/analysis/libsciast_la-ConstantValue.lo `test -f 'src/cpp/analysis/ConstantValue.cpp' || echo '$(srcdir)/'`src/cpp/analysis/ConstantValue.cpp
+
src/cpp/analysis/libsciast_la-ConstraintManager.lo: src/cpp/analysis/ConstraintManager.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/analysis/libsciast_la-ConstraintManager.lo -MD -MP -MF src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstraintManager.Tpo -c -o src/cpp/analysis/libsciast_la-ConstraintManager.lo `test -f 'src/cpp/analysis/ConstraintManager.cpp' || echo '$(srcdir)/'`src/cpp/analysis/ConstraintManager.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstraintManager.Tpo src/cpp/analysis/$(DEPDIR)/libsciast_la-ConstraintManager.Plo
<ClInclude Include="includes\analysis\checkers\check_uint8.hxx" />
<ClInclude Include="includes\analysis\checkers\check_zeros.hxx" />
<ClInclude Include="includes\analysis\Chrono.hxx" />
+ <ClInclude Include="includes\analysis\ConstantValue.hxx" />
+ <ClInclude Include="includes\analysis\ConstantVisitor.hxx" />
<ClInclude Include="includes\analysis\data\Block.hxx" />
<ClInclude Include="includes\analysis\data\CompleteMacroSignature.hxx" />
<ClInclude Include="includes\analysis\data\Data.hxx" />
<ClCompile Include="src\cpp\analysis\Block.cpp" />
<ClCompile Include="src\cpp\analysis\Checkers.cpp" />
<ClCompile Include="src\cpp\analysis\CompleteMacroSignature.cpp" />
+ <ClCompile Include="src\cpp\analysis\ConstantValue.cpp" />
<ClCompile Include="src\cpp\analysis\ConstraintManager.cpp" />
<ClCompile Include="src\cpp\analysis\DiagAnalyzer.cpp" />
<ClCompile Include="src\cpp\analysis\FunctionBlock.cpp" />
<ClInclude Include="includes\system_env\threadmanagement.hxx">
<Filter>Header Files\system_env</Filter>
</ClInclude>
+ <ClInclude Include="includes\analysis\ConstantValue.hxx">
+ <Filter>Header Files\analysis</Filter>
+ </ClInclude>
+ <ClInclude Include="includes\analysis\ConstantVisitor.hxx">
+ <Filter>Header Files\analysis</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\cpp\ast\debugvisitor.cpp">
<ClCompile Include="src\cpp\system_env\threadmanagement.cpp">
<Filter>Source Files\system_env</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\analysis\ConstantValue.cpp">
+ <Filter>Source Files\ast\analysis</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
{
symbol::Symbol & sym = e.getSymbol();
Info & info = dm.read(sym, &e);
- e.getDecorator().res = Result(info.type);
- double val;
- if (info.asDouble(val))
- {
- e.getDecorator().res.setValue(val);
- }
- else if (GVN::Value * gvnValue = info.getValue())
- {
- e.getDecorator().res.setGVNValue(gvnValue);
- }
-
- setResult(e.getDecorator().res);
+ Result & res = e.getDecorator().setResult(info.type);
+ res.setConstant(info.getConstant());
+ setResult(res);
}
void visit(ast::DollarVar & e)
void visit(ast::DoubleExp & e)
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), TIType::DOUBLE));
- e.getDecorator().res.setValue(e.getValue());
- setResult(e.getDecorator().res);
+ Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::DOUBLE));
+ res.getConstant().set(e.getValue());
+ setResult(res);
}
void visit(ast::BoolExp & e)
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), TIType::BOOLEAN));
- setResult(e.getDecorator().res);
+ Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::BOOLEAN));
+ res.getConstant().set(e.getValue());
+ setResult(res);
}
void visit(ast::StringExp & e)
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), TIType::STRING));
- setResult(e.getDecorator().res);
+ Result & res = e.getDecorator().setResult(TIType(dm.getGVN(), TIType::STRING));
+ res.getConstant().set(&e.getValue());
+ setResult(res);
}
void visit(ast::CommentExp & e)
var.getDecorator().res = RR;
Info & info = dm.define(sym, RR.getType(), &e);
double value;
- if (asDouble(e.getRightExp(), value) || RR.getValue(value))
+ if (asDouble(e.getRightExp(), value) || RR.getConstant().getDblValue(value))
{
- info.setValue(value);
+ info.getConstant().set(value);
}
- if (GVN::Value * gvnValue = RR.getGVNValue())
+ if (GVN::Value * gvnValue = RR.getConstant().getGVNValue())
{
- info.setValue(gvnValue);
+ info.getConstant().set(gvnValue);
}
}
}
ast::SimpleVar & var = *static_cast<ast::SimpleVar *>(exp);
symbol::Symbol & sym = var.getSymbol();
Info & info = dm.define(sym, j->getType(), exp);
- double value;
- if (j->getValue(value))
- {
- info.setValue(value);
- }
- if (GVN::Value * gvnValue = j->getGVNValue())
- {
- info.setValue(gvnValue);
- }
+ info.setConstant(j->getConstant());
++j;
}
}
namespace analysis
{
- class Call
+class Call
+{
+
+public:
+
+ enum Kind {UNDEFINED, IDENTITY, HYPOT, DOTHYPOT, __COUNT__};
+
+private:
+
+ Kind kind;
+ TIType type;
+ std::wstring name;
+ std::vector<TIType> args;
+
+public:
+
+ Call(Kind _kind, const TIType & _type, const std::wstring & _name, const std::vector<TIType> & _args) : kind(_kind),
+ type(_type),
+ name(_name),
+ args(_args) { }
+
+ Call(const TIType & _type, const std::wstring & _name, const std::vector<TIType> & _args) : Call(UNDEFINED, _type, _name, _args) { }
+ Call(Kind _kind, const TIType & _type, const std::wstring & _name) : kind(_kind),
+ type(_type),
+ name(_name) { }
+ Call(const TIType & _type, const std::wstring & _name) : Call(UNDEFINED, _type, _name) { }
+
+ Call(const std::wstring & _name) : kind(UNDEFINED), type(), name(_name) { }
+ Call(Call && call) : kind(call.kind), type(call.type), name(call.name), args(call.args) { }
+
+ inline void setName(const std::wstring & _name)
+ {
+ name = _name;
+ }
+
+ inline const std::wstring & getName() const
{
+ return name;
+ }
- public:
-
- enum Kind {UNDEFINED, IDENTITY, HYPOT, DOTHYPOT, __COUNT__};
-
- private:
-
- Kind kind;
- TIType type;
- std::wstring name;
- std::vector<TIType> args;
-
- public:
-
- Call(Kind _kind, const TIType & _type, const std::wstring & _name, const std::vector<TIType> & _args) : kind(_kind),
- type(_type),
- name(_name),
- args(_args) { }
-
- Call(const TIType & _type, const std::wstring & _name, const std::vector<TIType> & _args) : Call(UNDEFINED, _type, _name, _args) { }
- Call(Kind _kind, const TIType & _type, const std::wstring & _name) : kind(_kind),
- type(_type),
- name(_name) { }
- Call(const TIType & _type, const std::wstring & _name) : Call(UNDEFINED, _type, _name) { }
-
- Call(const std::wstring & _name) : kind(UNDEFINED), type(), name(_name) { }
- Call(Call && call) : kind(call.kind), type(call.type), name(call.name), args(call.args) { }
-
- inline void setName(const std::wstring & _name)
- {
- name = _name;
- }
-
- inline const std::wstring & getName() const
- {
- return name;
- }
-
- inline const TIType & getType() const
- {
- return type;
- }
-
- inline void setKind(Kind _kind)
- {
- kind = _kind;
- }
-
- inline Kind getKind() const
- {
- return kind;
- }
-
- inline void setArgs(const std::vector<TIType> & _args)
- {
- args = _args;
- }
-
- inline std::vector<TIType> & getArgs()
- {
- return args;
- }
-
- friend std::wostream & operator<<(std::wostream & out, const Call & res)
- {
- out << L"Call " << res.name << L"{" << res.type << L"}, Identity:" << (res.kind == IDENTITY ? L"T" : L"F");
- return out;
- }
- };
+ inline const TIType & getType() const
+ {
+ return type;
+ }
+
+ inline void setKind(Kind _kind)
+ {
+ kind = _kind;
+ }
+
+ inline Kind getKind() const
+ {
+ return kind;
+ }
+
+ inline void setArgs(const std::vector<TIType> & _args)
+ {
+ args = _args;
+ }
+
+ inline std::vector<TIType> & getArgs()
+ {
+ return args;
+ }
+
+ friend std::wostream & operator<<(std::wostream & out, const Call & res)
+ {
+ out << L"Call " << res.name << L"{" << res.type << L"}, Identity:" << (res.kind == IDENTITY ? L"T" : L"F");
+ return out;
+ }
+};
} // namespace analysis
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __CONSTANT_VALUE_HXX__
+#define __CONSTANT_VALUE_HXX__
+
+#include <complex>
+#include <iostream>
+#include <string>
+#include <type_traits>
+
+#include "gvn/GVN.hxx"
+
+namespace analysis
+{
+class ConstantValue
+{
+
+public:
+
+ enum Kind : unsigned char { DOUBLE, GVNVAL, STRING, BOOLEAN, COMPLEX, UNKNOWN };
+
+private:
+ union Value
+ {
+ double dbl;
+ GVN::Value * gvnVal;
+ const std::wstring * str = NULL;
+ bool boolean;
+ //std::complex<double> cplx;
+
+ Value() { }
+ Value(const double val) : dbl(val) { }
+ Value(GVN::Value * val) : gvnVal(val) { }
+ Value(const std::wstring * val) : str(val) { }
+ Value(const bool val) : boolean(val) { }
+ //Value(const std::complex<double> & val) : cplx(val) { }
+ };
+
+ Value val;
+ Kind kind;
+
+public:
+
+ ConstantValue() : kind(UNKNOWN) { }
+ ConstantValue(double _val) : val(_val), kind(DOUBLE) { }
+ ConstantValue(GVN::Value * _val) : val(_val), kind(GVNVAL) { }
+ ConstantValue(const std::wstring * _val) : val(_val), kind(STRING) { }
+ ConstantValue(bool _val) : val(_val), kind(BOOLEAN) { }
+ //ConstantValue(const std::complex<double> & _val) : val(_val), kind(COMPLEX) { }
+
+ inline Kind getKind() const
+ {
+ return kind;
+ }
+
+ inline bool isKnown() const
+ {
+ return kind != UNKNOWN;
+ }
+
+ inline bool getDblValue(double & _val) const
+ {
+ if (kind == DOUBLE)
+ {
+ _val = val.dbl;
+ return true;
+ }
+ else if (kind == GVNVAL)
+ {
+ if (GVN::Value * gvnValue = val.gvnVal)
+ {
+ if (gvnValue->poly->isConstant())
+ {
+ _val = gvnValue->poly->constant;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ inline GVN::Value * getGVNValue() const
+ {
+ if (kind == ConstantValue::GVNVAL)
+ {
+ return val.gvnVal;
+ }
+
+ return nullptr;
+ }
+
+ template<typename T> inline void set(T _val);
+ template<typename T> inline T get() const;
+
+ void merge(const ConstantValue & cv);
+
+ friend std::wostream & operator<<(std::wostream & out, const ConstantValue & cv)
+ {
+ switch (cv.kind)
+ {
+ case ConstantValue::DOUBLE:
+ out << cv.val.dbl;
+ break;
+ case ConstantValue::GVNVAL:
+ out << *cv.val.gvnVal;
+ break;
+ case ConstantValue::STRING:
+ out << L"\"" << *cv.val.str << L"\"";
+ break;
+ case ConstantValue::BOOLEAN:
+ out << (cv.val.boolean ? L"T" : L"F");
+ break;
+ //case ConstantValue::COMPLEX:
+ // out << cv.val.cplx.real() << L"+i*" << cv.val.cplx.imag();
+ // break;
+ default:
+ break;
+ }
+
+ return out;
+ }
+
+private:
+
+ template<typename T, bool Ptr>
+ struct __merge
+ {
+ inline void operator()(ConstantValue & cv1, const ConstantValue & cv2);
+ };
+
+ template<typename T>
+ struct __merge<T, true>
+ {
+ inline void operator()(ConstantValue & cv1, const ConstantValue & cv2)
+ {
+ T t1 = cv1.get<T>();
+ T t2 = cv2.get<T>();
+ if (t1 != t2 && *t1 != *t2)
+ {
+ cv1.kind = UNKNOWN;
+ }
+ }
+ };
+
+ template<typename T>
+ struct __merge<T, false>
+ {
+ inline void operator()(ConstantValue & cv1, const ConstantValue & cv2)
+ {
+ if (cv1.get<T>() != cv2.get<T>())
+ {
+ cv1.kind = UNKNOWN;
+ }
+ }
+ };
+
+ template<typename T>
+ inline void merge(const ConstantValue & cv)
+ {
+ __merge<T, std::is_pointer<T>::value>()(*this, cv);
+ }
+
+};
+
+template<> inline void ConstantValue::set<>(int _val)
+{
+ val = (double)_val;
+ kind = DOUBLE;
+}
+template<> inline void ConstantValue::set<>(unsigned int _val)
+{
+ val = (double)_val;
+ kind = DOUBLE;
+}
+template<> inline void ConstantValue::set<>(double _val)
+{
+ val = _val;
+ kind = DOUBLE;
+}
+template<> inline void ConstantValue::set<>(GVN::Value * _val)
+{
+ val = _val;
+ kind = GVNVAL;
+}
+template<> inline void ConstantValue::set<>(const std::wstring * _val)
+{
+ val = _val;
+ kind = STRING;
+}
+template<> inline void ConstantValue::set<>(bool _val)
+{
+ val = _val;
+ kind = BOOLEAN;
+}
+//template<> inline void ConstantValue::set<>(std::complex<double> && _val)
+//{
+// val = _val;
+// kind = COMPLEX;
+//}
+
+template<> inline double ConstantValue::get<>() const
+{
+ return val.dbl;
+}
+template<> inline GVN::Value * ConstantValue::get<>() const
+{
+ return val.gvnVal;
+}
+template<> inline const std::wstring * ConstantValue::get<>() const
+{
+ return val.str;
+}
+template<> inline bool ConstantValue::get<>() const
+{
+ return val.boolean;
+}
+//template<> inline const std::complex<double> & ConstantValue::get<>() const
+//{
+// return val.cplx;
+//}
+
+} // namespace analysis
+
+#endif // __CONSTANT_VALUE_HXX__
namespace analysis
{
- struct Decorator
- {
- Result res;
- Call * call;
- bool cloneData;
- bool deleteData;
- bool hasRefCount;
+struct Decorator
+{
+ Result res;
+ Call * call;
+ bool cloneData;
+ bool deleteData;
+ bool hasRefCount;
- Decorator() : res(), call(nullptr), cloneData(false), deleteData(false), hasRefCount(false) { }
+ Decorator() : res(), call(nullptr), cloneData(false), deleteData(false), hasRefCount(false) { }
- ~Decorator()
- {
- delete call;
- }
+ ~Decorator()
+ {
+ delete call;
+ }
- inline Call * getCall() const
- {
- return call;
- }
+ inline Call * getCall() const
+ {
+ return call;
+ }
- inline Call & setCall(Call && call)
- {
- this->call = new Call(std::move(call));
- return *this->call;
- }
+ inline Call & setCall(Call && call)
+ {
+ this->call = new Call(std::move(call));
+ return *this->call;
+ }
- inline Call & setCall(Call * call)
- {
- this->call = call;
- return *this->call;
- }
+ inline Call & setCall(Call * call)
+ {
+ this->call = call;
+ return *this->call;
+ }
+
+ inline Result & setResult(Result && _res)
+ {
+ res = _res;
+ return res;
+ }
- friend std::wostream & operator<<(std::wostream & out, const Decorator & deco)
- {
- out << deco.res;
- if (deco.call)
- {
- out << L", " << (*deco.call);
- }
- out << L", Cl:" << (deco.cloneData ? L"T" : L"F")
- << L", Del:" << (deco.deleteData ? L"T" : L"F")
- << L", RefC:" << (deco.hasRefCount ? L"T" : L"F");
+ friend std::wostream & operator<<(std::wostream & out, const Decorator & deco)
+ {
+ out << deco.res;
+ if (deco.call)
+ {
+ out << L", " << (*deco.call);
+ }
+ out << L", Cl:" << (deco.cloneData ? L"T" : L"F")
+ << L", Del:" << (deco.deleteData ? L"T" : L"F")
+ << L", RefC:" << (deco.hasRefCount ? L"T" : L"F");
- return out;
- }
- };
+ return out;
+ }
+};
} // namespace analysis
#include "gvn/GVN.hxx"
#include "TIType.hxx"
#include "tools.hxx"
+#include "ConstantValue.hxx"
namespace analysis
{
- class Result
+class Result
+{
+
+public:
+
+ enum FnName { ZEROS, ONES, RAND, DUNNO };
+
+private:
+
+ bool visited;
+ TIType type;
+ int tempId;
+ FnName fnname;
+ ConstantValue constant;
+
+public:
+
+ Result() : visited(false), type(), tempId(-1) { }
+ Result(const TIType & _type, const int _tempId = -1) : visited(true), type(_type), tempId(_tempId) { }
+ Result(TIType && _type, const int _tempId = -1) : visited(true), type(_type), tempId(_tempId) { }
+
+ inline bool istemp() const
+ {
+ return tempId >= 0;
+ }
+
+ inline void setFnName(FnName _fnname)
+ {
+ visited = true;
+ fnname = _fnname;
+ }
+
+ inline FnName getFnName() const
+ {
+ return fnname;
+ }
+
+ inline const TIType & getType() const
{
+ return type;
+ }
- public:
-
- enum FnName { ZEROS, ONES, RAND, DUNNO };
-
- private:
-
- bool visited;
- TIType type;
- tools::IntType inttype;
- int tempId;
- FnName fnname;
- double value;
- bool hasValue;
- GVN::Value * gvnValue;
-
- public:
-
- Result() : visited(false), type(), inttype(tools::NOTANINT), tempId(-1), hasValue(false), gvnValue(nullptr) { }
- Result(const TIType & _type, const int _tempId = -1) : visited(true), type(_type), inttype(tools::NOTANINT), tempId(_tempId), hasValue(false), gvnValue(nullptr) { }
- Result(TIType && _type, const int _tempId = -1) : visited(true), type(_type), inttype(tools::NOTANINT), tempId(_tempId), hasValue(false), gvnValue(nullptr) { }
-
- inline bool istemp() const
- {
- return tempId >= 0;
- }
-
- inline void setFnName(FnName _fnname)
- {
- visited = true;
- fnname = _fnname;
- }
-
- inline FnName getFnName() const
- {
- return fnname;
- }
-
- inline const TIType & getType() const
- {
- return type;
- }
-
- inline TIType & getType()
- {
- return type;
- }
-
- inline int getTempId() const
- {
- return tempId;
- }
-
- inline tools::IntType getIntType() const
- {
- return inttype;
- }
-
- inline void setIntType(tools::IntType it)
- {
- visited = true;
- inttype = it;
- }
-
- inline void setValue(const double _value)
- {
- setValue(_value, tools::getIntType(_value));
- }
-
- inline void setValue(const double _value, const tools::IntType _inttype)
- {
- value = _value;
- inttype = _inttype;
- hasValue = true;
- visited = true;
- }
-
- inline void setGVNValue(GVN::Value * _value)
- {
- gvnValue = _value;
- }
-
- inline GVN::Value * getGVNValue()
- {
- return gvnValue;
- }
-
- inline bool getValue(double & _value)
- {
- if (hasValue)
- {
- _value = value;
- return true;
- }
- return false;
- }
-
- inline bool hasBeenVisited() const
- {
- return visited;
- }
-
- friend std::wostream & operator<<(std::wostream & out, const Result & res)
- {
- out << L"Result {" << res.type << L", temp id:" << res.tempId << L", int:" << res.inttype << L"}";
- return out;
- }
- };
+ inline TIType & getType()
+ {
+ return type;
+ }
+
+ inline int getTempId() const
+ {
+ return tempId;
+ }
+
+ inline ConstantValue & getConstant()
+ {
+ return constant;
+ }
+
+ inline const ConstantValue & getConstant() const
+ {
+ return constant;
+ }
+
+ inline ConstantValue & setConstant(ConstantValue & val)
+ {
+ constant = val;
+ return constant;
+ }
+
+ inline bool hasBeenVisited() const
+ {
+ return visited;
+ }
+
+ friend std::wostream & operator<<(std::wostream & out, const Result & res)
+ {
+ out << L"Result {" << res.type << L", temp id:" << res.tempId << L", constant:" << res.constant << L"}";
+ return out;
+ }
+};
} // namespace analysis
namespace analysis
{
- struct TIType
+struct TIType
+{
+ enum Type { EMPTY = 0, BOOLEAN, COMPLEX, CELL, DOUBLE, DOUBLEUINT, FUNCTION, INT16, INT32, INT64, INT8, LIST, LIBRARY, MACRO, MACROFILE, MLIST, POLYNOMIAL, STRING, SPARSE, STRUCT, TLIST, UINT16, UINT32, UINT64, UINT8, UNKNOWN, COUNT };
+ Type type;
+ SymbolicDimension rows;
+ SymbolicDimension cols;
+ bool scalar;
+
+ TIType(const Type _type = UNKNOWN) : type(_type), scalar(true) { }
+ TIType(GVN & gvn) : type(UNKNOWN), rows(gvn, tools::NaN()), cols(gvn, tools::NaN()), scalar(false) { }
+ TIType(GVN & gvn, const Type _type) : type(_type), rows(gvn, _type == EMPTY ? 0 : 1), cols(gvn, _type == EMPTY ? 0 : 1), scalar(_type != EMPTY) { }
+ TIType(GVN & gvn, const Type _type, const int _rows, const int _cols) : type(_type), rows(gvn, _rows), cols(gvn, _cols), scalar(_rows == 1 && _cols == 1) { }
+ TIType(GVN & gvn, Type _type, const SymbolicDimension & _rows, const SymbolicDimension & _cols) : type(_type), rows(_rows), cols(_cols), scalar(_rows == 1 && _cols == 1) { }
+ TIType(GVN & gvn, const Type _type, const bool _scalar, const bool _unknown) : type(_type), rows(gvn, getDimValue(_scalar, _unknown)), cols(gvn, getDimValue(_scalar, _unknown)), scalar(_scalar) { }
+
+ inline static double getDimValue(const bool scalar, const bool unknown)
{
- enum Type { EMPTY = 0, BOOLEAN, COMPLEX, CELL, DOUBLE, DOUBLEUINT, FUNCTION, INT16, INT32, INT64, INT8, LIST, LIBRARY, MACRO, MACROFILE, MLIST, POLYNOMIAL, STRING, SPARSE, STRUCT, TLIST, UINT16, UINT32, UINT64, UINT8, UNKNOWN, COUNT };
- Type type;
- SymbolicDimension rows;
- SymbolicDimension cols;
- bool scalar;
-
- TIType(const Type _type = UNKNOWN) : type(_type), scalar(true) { }
- TIType(GVN & gvn) : type(UNKNOWN), rows(gvn, tools::NaN()), cols(gvn, tools::NaN()), scalar(false) { }
- TIType(GVN & gvn, const Type _type) : type(_type), rows(gvn, _type == EMPTY ? 0 : 1), cols(gvn, _type == EMPTY ? 0 : 1), scalar(_type != EMPTY) { }
- TIType(GVN & gvn, const Type _type, const int _rows, const int _cols) : type(_type), rows(gvn, _rows), cols(gvn, _cols), scalar(_rows == 1 && _cols == 1) { }
- TIType(GVN & gvn, Type _type, const SymbolicDimension & _rows, const SymbolicDimension & _cols) : type(_type), rows(_rows), cols(_cols), scalar(_rows == 1 && _cols == 1) { }
- TIType(GVN & gvn, const Type _type, const bool _scalar, const bool _unknown) : type(_type), rows(gvn, getDimValue(_scalar, _unknown)), cols(gvn, getDimValue(_scalar, _unknown)), scalar(_scalar) { }
-
- inline static double getDimValue(const bool scalar, const bool unknown)
- {
- return scalar ? 1. : (unknown ? tools::NaN() : -1.);
- }
-
- inline TIType asMatrix()
- {
- return TIType(*rows.getGVN(), type, 0, 0);
- }
-
- inline TIType asUnknownMatrix()
- {
- return TIType(*rows.getGVN(), type, false, true);
- }
-
- inline bool isscalar() const
- {
- return scalar;
- }
+ return scalar ? 1. : (unknown ? tools::NaN() : -1.);
+ }
- inline void invalidScalar()
- {
- scalar = rows == 1 && cols == 1;
- }
+ inline TIType asMatrix()
+ {
+ return TIType(*rows.getGVN(), type, 0, 0);
+ }
- inline bool iscomplex() const
- {
- return type == COMPLEX;
- }
+ inline TIType asUnknownMatrix()
+ {
+ return TIType(*rows.getGVN(), type, false, true);
+ }
- inline bool isreal() const
- {
- return type == DOUBLE;
- }
+ inline bool isscalar() const
+ {
+ return scalar;
+ }
- inline bool isintegral() const
- {
- return type == BOOLEAN || type == INT8 || type == INT16 || type == INT32 || type == INT64 || type == UINT8 || type == UINT16 || type == UINT32 || type == UINT64;
- }
+ inline void invalidScalar()
+ {
+ scalar = rows == 1 && cols == 1;
+ }
- inline bool ismatrix() const
- {
- return type != CELL && type != FUNCTION && type != LIST && type != LIBRARY && type != MACRO && type != MACROFILE && type != MLIST && type != STRUCT && type != TLIST && type != UNKNOWN;
- }
+ inline bool iscomplex() const
+ {
+ return type == COMPLEX;
+ }
- inline bool issigned() const
- {
- return type != UINT8 && type != UINT16 && type != UINT32 && type != UINT64;
- }
+ inline bool isreal() const
+ {
+ return type == DOUBLE;
+ }
- inline bool isfloating() const
- {
- return type == DOUBLE || type == COMPLEX;
- }
+ inline bool isintegral() const
+ {
+ return type == BOOLEAN || type == INT8 || type == INT16 || type == INT32 || type == INT64 || type == UINT8 || type == UINT16 || type == UINT32 || type == UINT64;
+ }
- inline bool isKnownDims() const
- {
- return rows.isValid() && cols.isValid();
- }
+ inline bool ismatrix() const
+ {
+ return type != CELL && type != FUNCTION && type != LIST && type != LIBRARY && type != MACRO && type != MACROFILE && type != MLIST && type != STRUCT && type != TLIST && type != UNKNOWN;
+ }
- inline bool isUnknownDims() const
- {
- return !isKnownDims();
- }
+ inline bool issigned() const
+ {
+ return type != UINT8 && type != UINT16 && type != UINT32 && type != UINT64;
+ }
- inline bool isknown() const
- {
- return type != UNKNOWN;
- }
+ inline bool isfloating() const
+ {
+ return type == DOUBLE || type == COMPLEX;
+ }
- inline bool isConstantDims() const
- {
- return rows.isConstant() && cols.isConstant();
- }
+ inline bool isKnownDims() const
+ {
+ return rows.isValid() && cols.isValid();
+ }
- inline std::size_t hashPureType() const
- {
- return isscalar() ? type : (type + TIType::COUNT + 1);
- }
+ inline bool isUnknownDims() const
+ {
+ return !isKnownDims();
+ }
- inline bool operator==(const TIType & r) const
- {
- return type == r.type && scalar == r.scalar && rows == r.rows && cols == r.cols;
- }
+ inline bool isknown() const
+ {
+ return type != UNKNOWN;
+ }
- inline bool operator!=(const TIType & r) const
- {
- return !(*this == r);
- }
+ inline bool isConstantDims() const
+ {
+ return rows.isConstant() && cols.isConstant();
+ }
- inline void merge(const TIType & type)
- {
- if (this->type == DOUBLE && type.type == COMPLEX)
- {
- this->type = COMPLEX;
- }
- else if ((this->type != COMPLEX || type.type != DOUBLE) && this->type != type.type)
- {
- this->type = UNKNOWN;
- }
- else if ((!scalar || !type.scalar) && (rows != type.rows || cols != type.cols))
- {
- rows.invalid();
- cols.invalid();
- scalar = false;
- }
- }
+ inline std::size_t hashPureType() const
+ {
+ return isscalar() ? type : (type + TIType::COUNT + 1);
+ }
- template<typename> static Type getTI();
+ inline bool operator==(const TIType & r) const
+ {
+ return type == r.type && scalar == r.scalar && rows == r.rows && cols == r.cols;
+ }
- inline std::string get_mangling() const
- {
- const bool kd = isKnownDims();
- switch (type)
- {
- case EMPTY :
- return "E";
- case BOOLEAN :
- return kd ? (scalar ? "S_b" : "M_b") : "U_b";
- case COMPLEX :
- return kd ? (scalar ? "S_c" : "M_c") : "U_c";
- case CELL :
- return kd ? (scalar ? "S_ce" : "M_ce") : "U_ce";
- case DOUBLE :
- return kd ? (scalar ? "S_d" : "M_d") : "U_d";
- case DOUBLEUINT :
- return kd ? (scalar ? "S_dui" : "M_dui") : "U_dui";
- case FUNCTION :
- return kd ? (scalar ? "S_fn" : "M_fn") : "U_fn";
- case INT16 :
- return kd ? (scalar ? "S_i16" : "M_i16") : "U_i16";
- case INT32 :
- return kd ? (scalar ? "S_i32" : "M_i32") : "U_i32";
- case INT64 :
- return kd ? (scalar ? "S_i64" : "M_i64") : "U_i64";
- case INT8 :
- return kd ? (scalar ? "S_i8" : "M_i8") : "U_i8";
- case LIST :
- return kd ? (scalar ? "S_l" : "M_l") : "U_l";
- case LIBRARY :
- return kd ? (scalar ? "S_lb" : "M_lb") : "U_lb";
- case MACRO :
- return kd ? (scalar ? "S_m" : "M_m") : "U_m";
- case MACROFILE :
- return kd ? (scalar ? "S_mf" : "M_mf") : "U_mf";
- case MLIST :
- return kd ? (scalar ? "S_ml" : "M_ml") : "U_ml";
- case POLYNOMIAL :
- return kd ? (scalar ? "S_p" : "M_p") : "U_p";
- case STRING :
- return kd ? (scalar ? "S_s" : "M_s") : "U_s";
- case SPARSE :
- return kd ? (scalar ? "S_sp" : "M_sp") : "U_sp";
- case STRUCT :
- return kd ? (scalar ? "S_st" : "M_st") : "U_st";
- case TLIST :
- return kd ? (scalar ? "S_tl" : "M_tl") : "U_tl";
- case UINT16 :
- return kd ? (scalar ? "S_ui16" : "M_ui16") : "U_ui16";
- case UINT32 :
- return kd ? (scalar ? "S_ui32" : "M_ui32") : "U_ui32";
- case UINT64 :
- return kd ? (scalar ? "S_ui64" : "M_ui64") : "U_ui64";
- case UINT8 :
- return kd ? (scalar ? "S_ui8" : "M_ui8") : "U_ui8";
- default :
- return "??";
- }
- }
+ inline bool operator!=(const TIType & r) const
+ {
+ return !(*this == r);
+ }
- inline static std::string get_unary_mangling(const std::string & pre, const TIType & l)
- {
- return pre + "_" + l.get_mangling();
- }
+ inline void merge(const TIType & type)
+ {
+ if (this->type == DOUBLE && type.type == COMPLEX)
+ {
+ this->type = COMPLEX;
+ }
+ else if ((this->type != COMPLEX || type.type != DOUBLE) && this->type != type.type)
+ {
+ this->type = UNKNOWN;
+ }
+ else if ((!scalar || !type.scalar) && (rows != type.rows || cols != type.cols))
+ {
+ rows.invalid();
+ cols.invalid();
+ scalar = false;
+ }
+ }
+
+ template<typename> static Type getTI();
+
+ inline std::string get_mangling() const
+ {
+ const bool kd = isKnownDims();
+ switch (type)
+ {
+ case EMPTY :
+ return "E";
+ case BOOLEAN :
+ return kd ? (scalar ? "S_b" : "M_b") : "U_b";
+ case COMPLEX :
+ return kd ? (scalar ? "S_c" : "M_c") : "U_c";
+ case CELL :
+ return kd ? (scalar ? "S_ce" : "M_ce") : "U_ce";
+ case DOUBLE :
+ return kd ? (scalar ? "S_d" : "M_d") : "U_d";
+ case DOUBLEUINT :
+ return kd ? (scalar ? "S_dui" : "M_dui") : "U_dui";
+ case FUNCTION :
+ return kd ? (scalar ? "S_fn" : "M_fn") : "U_fn";
+ case INT16 :
+ return kd ? (scalar ? "S_i16" : "M_i16") : "U_i16";
+ case INT32 :
+ return kd ? (scalar ? "S_i32" : "M_i32") : "U_i32";
+ case INT64 :
+ return kd ? (scalar ? "S_i64" : "M_i64") : "U_i64";
+ case INT8 :
+ return kd ? (scalar ? "S_i8" : "M_i8") : "U_i8";
+ case LIST :
+ return kd ? (scalar ? "S_l" : "M_l") : "U_l";
+ case LIBRARY :
+ return kd ? (scalar ? "S_lb" : "M_lb") : "U_lb";
+ case MACRO :
+ return kd ? (scalar ? "S_m" : "M_m") : "U_m";
+ case MACROFILE :
+ return kd ? (scalar ? "S_mf" : "M_mf") : "U_mf";
+ case MLIST :
+ return kd ? (scalar ? "S_ml" : "M_ml") : "U_ml";
+ case POLYNOMIAL :
+ return kd ? (scalar ? "S_p" : "M_p") : "U_p";
+ case STRING :
+ return kd ? (scalar ? "S_s" : "M_s") : "U_s";
+ case SPARSE :
+ return kd ? (scalar ? "S_sp" : "M_sp") : "U_sp";
+ case STRUCT :
+ return kd ? (scalar ? "S_st" : "M_st") : "U_st";
+ case TLIST :
+ return kd ? (scalar ? "S_tl" : "M_tl") : "U_tl";
+ case UINT16 :
+ return kd ? (scalar ? "S_ui16" : "M_ui16") : "U_ui16";
+ case UINT32 :
+ return kd ? (scalar ? "S_ui32" : "M_ui32") : "U_ui32";
+ case UINT64 :
+ return kd ? (scalar ? "S_ui64" : "M_ui64") : "U_ui64";
+ case UINT8 :
+ return kd ? (scalar ? "S_ui8" : "M_ui8") : "U_ui8";
+ default :
+ return "??";
+ }
+ }
+
+ inline static std::string get_unary_mangling(const std::string & pre, const TIType & l)
+ {
+ return pre + "_" + l.get_mangling();
+ }
- inline static std::string get_binary_mangling(const std::string & pre, const TIType & l, const TIType & r)
- {
- return pre + "_" + l.get_mangling() + "_" + r.get_mangling();
- }
+ inline static std::string get_binary_mangling(const std::string & pre, const TIType & l, const TIType & r)
+ {
+ return pre + "_" + l.get_mangling() + "_" + r.get_mangling();
+ }
- inline static std::string get_mangling(const std::string & pre, const std::vector<TIType> & types)
+ inline static std::string get_mangling(const std::string & pre, const std::vector<TIType> & types)
+ {
+ std::string s(pre);
+ for (std::vector<TIType>::const_iterator i = types.begin(), end = types.end(); i != end; ++i)
+ {
+ s += "_" + i->get_mangling();
+ }
+ return s;
+ }
+
+ inline static unsigned int get_base_size(const Type type)
+ {
+ switch (type)
+ {
+ case EMPTY :
+ return sizeof(double);
+ case BOOLEAN :
+ return sizeof(int);
+ case DOUBLE :
+ return sizeof(double);
+ case INT8 :
+ return sizeof(int8_t);
+ case INT16 :
+ return sizeof(int16_t);
+ case INT32 :
+ return sizeof(int32_t);
+ case INT64 :
+ return sizeof(int64_t);
+ case UINT8 :
+ return sizeof(uint8_t);
+ case UINT16 :
+ return sizeof(uint16_t);
+ case UINT32 :
+ return sizeof(uint32_t);
+ case UINT64 :
+ return sizeof(uint64_t);
+ default :
+ return 0;
+ }
+ }
+
+ inline static std::wstring toString(Type t)
+ {
+ switch (t)
+ {
+ case EMPTY :
+ return L"[]";
+ case BOOLEAN :
+ return L"boolean";
+ case COMPLEX :
+ return L"complex";
+ case CELL :
+ return L"cell";
+ case DOUBLE :
+ return L"double";
+ case DOUBLEUINT :
+ return L"doubleuint";
+ case FUNCTION :
+ return L"function";
+ case INT16 :
+ return L"int16";
+ case INT32 :
+ return L"int32";
+ case INT64 :
+ return L"int64";
+ case INT8 :
+ return L"int8";
+ case LIST :
+ return L"list";
+ case LIBRARY :
+ return L"library";
+ case MACRO :
+ return L"macro";
+ case MACROFILE :
+ return L"macrofile";
+ case MLIST :
+ return L"mlist";
+ case POLYNOMIAL :
+ return L"polynomial";
+ case STRING :
+ return L"string";
+ case SPARSE :
+ return L"sparse";
+ case STRUCT :
+ return L"struct";
+ case TLIST :
+ return L"tlist";
+ case UINT16 :
+ return L"uint16";
+ case UINT32 :
+ return L"uint32";
+ case UINT64 :
+ return L"uint64";
+ case UINT8 :
+ return L"uint8";
+ default:
+ break;
+ }
+
+ return L"unknown";
+ }
+
+ friend std::wostream & operator<<(std::wostream & out, const TIType & type)
+ {
+ switch (type.type)
+ {
+ case EMPTY :
+ out << L"[]";
+ break;
+ case BOOLEAN :
+ out << L"boolean";
+ break;
+ case COMPLEX :
+ out << L"complex";
+ break;
+ case CELL :
+ out << L"cell";
+ break;
+ case DOUBLE :
+ out << L"double";
+ break;
+ case DOUBLEUINT :
+ out << L"doubleuint";
+ break;
+ case FUNCTION :
+ out << L"function";
+ break;
+ case INT16 :
+ out << L"int16";
+ break;
+ case INT32 :
+ out << L"int32";
+ break;
+ case INT64 :
+ out << L"int64";
+ break;
+ case INT8 :
+ out << L"int8";
+ break;
+ case LIST :
+ out << L"list";
+ break;
+ case LIBRARY :
+ out << L"library";
+ break;
+ case MACRO :
+ out << L"macro";
+ break;
+ case MACROFILE :
+ out << L"macrofile";
+ break;
+ case MLIST :
+ out << L"mlist";
+ break;
+ case POLYNOMIAL :
+ out << L"polynomial";
+ break;
+ case STRING :
+ out << L"string";
+ break;
+ case SPARSE :
+ out << L"sparse";
+ break;
+ case STRUCT :
+ out << L"struct";
+ break;
+ case TLIST :
+ out << L"tlist";
+ break;
+ case UINT16 :
+ out << L"uint16";
+ break;
+ case UINT32 :
+ out << L"uint32";
+ break;
+ case UINT64 :
+ out << L"uint64";
+ break;
+ case UINT8 :
+ out << L"uint8";
+ break;
+ default:
+ out << L"unknown";
+ }
+
+ if (type.type != EMPTY && type.type != UNKNOWN)
+ {
+ if (type.isUnknownDims())
{
- std::string s(pre);
- for (std::vector<TIType>::const_iterator i = types.begin(), end = types.end(); i != end; ++i)
- {
- s += "_" + i->get_mangling();
- }
- return s;
+ out << L"[?, ?]";
}
-
- inline static unsigned int get_base_size(const Type type)
+ else
{
- switch (type)
- {
- case EMPTY :
- return sizeof(double);
- case BOOLEAN :
- return sizeof(int);
- case DOUBLE :
- return sizeof(double);
- case INT8 :
- return sizeof(int8_t);
- case INT16 :
- return sizeof(int16_t);
- case INT32 :
- return sizeof(int32_t);
- case INT64 :
- return sizeof(int64_t);
- case UINT8 :
- return sizeof(uint8_t);
- case UINT16 :
- return sizeof(uint16_t);
- case UINT32 :
- return sizeof(uint32_t);
- case UINT64 :
- return sizeof(uint64_t);
- default :
- return 0;
- }
+ out << L"[" << type.rows << L", " << type.cols << L"]";
}
+ }
- inline static std::wstring toString(Type t)
- {
- switch (t)
- {
- case EMPTY :
- return L"[]";
- case BOOLEAN :
- return L"boolean";
- case COMPLEX :
- return L"complex";
- case CELL :
- return L"cell";
- case DOUBLE :
- return L"double";
- case DOUBLEUINT :
- return L"doubleuint";
- case FUNCTION :
- return L"function";
- case INT16 :
- return L"int16";
- case INT32 :
- return L"int32";
- case INT64 :
- return L"int64";
- case INT8 :
- return L"int8";
- case LIST :
- return L"list";
- case LIBRARY :
- return L"library";
- case MACRO :
- return L"macro";
- case MACROFILE :
- return L"macrofile";
- case MLIST :
- return L"mlist";
- case POLYNOMIAL :
- return L"polynomial";
- case STRING :
- return L"string";
- case SPARSE :
- return L"sparse";
- case STRUCT :
- return L"struct";
- case TLIST :
- return L"tlist";
- case UINT16 :
- return L"uint16";
- case UINT32 :
- return L"uint32";
- case UINT64 :
- return L"uint64";
- case UINT8 :
- return L"uint8";
- case UNKNOWN :
- return L"unknown";
- }
- }
+ return out;
+ }
+};
- friend std::wostream & operator<<(std::wostream & out, const TIType & type)
- {
- switch (type.type)
- {
- case EMPTY :
- out << L"[]";
- break;
- case BOOLEAN :
- out << L"boolean";
- break;
- case COMPLEX :
- out << L"complex";
- break;
- case CELL :
- out << L"cell";
- break;
- case DOUBLE :
- out << L"double";
- break;
- case DOUBLEUINT :
- out << L"doubleuint";
- break;
- case FUNCTION :
- out << L"function";
- break;
- case INT16 :
- out << L"int16";
- break;
- case INT32 :
- out << L"int32";
- break;
- case INT64 :
- out << L"int64";
- break;
- case INT8 :
- out << L"int8";
- break;
- case LIST :
- out << L"list";
- break;
- case LIBRARY :
- out << L"library";
- break;
- case MACRO :
- out << L"macro";
- break;
- case MACROFILE :
- out << L"macrofile";
- break;
- case MLIST :
- out << L"mlist";
- break;
- case POLYNOMIAL :
- out << L"polynomial";
- break;
- case STRING :
- out << L"string";
- break;
- case SPARSE :
- out << L"sparse";
- break;
- case STRUCT :
- out << L"struct";
- break;
- case TLIST :
- out << L"tlist";
- break;
- case UINT16 :
- out << L"uint16";
- break;
- case UINT32 :
- out << L"uint32";
- break;
- case UINT64 :
- out << L"uint64";
- break;
- case UINT8 :
- out << L"uint8";
- break;
- case UNKNOWN :
- out << L"unknown";
- }
-
- if (type.type != EMPTY && type.type != UNKNOWN)
- {
- if (type.isUnknownDims())
- {
- out << L"[?, ?]";
- }
- else
- {
- out << L"[" << type.rows << L", " << type.cols << L"]";
- }
- }
-
- return out;
- }
- };
-
- template<> inline TIType::Type TIType::getTI<bool>() { return TIType::BOOLEAN; }
- template<> inline TIType::Type TIType::getTI<double>() { return TIType::DOUBLE; }
- template<> inline TIType::Type TIType::getTI<int16_t>() { return TIType::INT16; }
- template<> inline TIType::Type TIType::getTI<int32_t>() { return TIType::INT32; }
- template<> inline TIType::Type TIType::getTI<int64_t>() { return TIType::INT64; }
- template<> inline TIType::Type TIType::getTI<int8_t>() { return TIType::INT8; }
- template<> inline TIType::Type TIType::getTI<uint16_t>() { return TIType::UINT16; }
- template<> inline TIType::Type TIType::getTI<uint32_t>() { return TIType::UINT32; }
- template<> inline TIType::Type TIType::getTI<uint64_t>() { return TIType::UINT64; }
- template<> inline TIType::Type TIType::getTI<uint8_t>() { return TIType::UINT8; }
+template<> inline TIType::Type TIType::getTI<bool>()
+{
+ return TIType::BOOLEAN;
+}
+template<> inline TIType::Type TIType::getTI<double>()
+{
+ return TIType::DOUBLE;
+}
+template<> inline TIType::Type TIType::getTI<int16_t>()
+{
+ return TIType::INT16;
+}
+template<> inline TIType::Type TIType::getTI<int32_t>()
+{
+ return TIType::INT32;
+}
+template<> inline TIType::Type TIType::getTI<int64_t>()
+{
+ return TIType::INT64;
+}
+template<> inline TIType::Type TIType::getTI<int8_t>()
+{
+ return TIType::INT8;
+}
+template<> inline TIType::Type TIType::getTI<uint16_t>()
+{
+ return TIType::UINT16;
+}
+template<> inline TIType::Type TIType::getTI<uint32_t>()
+{
+ return TIType::UINT32;
+}
+template<> inline TIType::Type TIType::getTI<uint64_t>()
+{
+ return TIType::UINT64;
+}
+template<> inline TIType::Type TIType::getTI<uint8_t>()
+{
+ return TIType::UINT8;
+}
} // namespace analysis
namespace std
{
- // useful to be able to put TIType in unorderd_set for example.
- template<>
- struct hash<analysis::TIType>
+// useful to be able to put TIType in unorderd_set for example.
+template<>
+struct hash<analysis::TIType>
+{
+ inline size_t operator()(const analysis::TIType & t) const
{
- inline size_t operator()(const analysis::TIType & t) const
- {
- return 0;//tools::hash_combine(t.type, t.rows, t.cols);
- }
- };
+ return 0;//tools::hash_combine(t.type, t.rows, t.cols);
+ }
+};
} // namespace std
#endif // __TITYPE_HXX__
#include "TIType.hxx"
#include "Data.hxx"
#include "gvn/GVN.hxx"
-#include "dynlib_ast.h"
+#include "ConstantValue.hxx"
+
namespace analysis
{
-struct EXTERN_AST Info
+struct Info
{
enum Local
{
Local local;
bool cleared;
bool exists;
- bool knownValue;
- double value;
TIType type;
Data * data;
- GVN::Value * gvnValue;
ast::Exp * exp;
+ ConstantValue constant;
- Info(Data * _data = nullptr) : R(false), W(false), O(false), isint(false), local(Local::INFO_TRUE), cleared(false), exists(true), knownValue(false), data(_data), gvnValue(nullptr), exp(nullptr) { }
- Info(const Info & i) : R(i.R), W(i.W), O(i.O), isint(i.isint), local(i.local), cleared(i.cleared), exists(i.exists), knownValue(i.knownValue), value(i.value), type(i.type), data(i.data ? new Data(*i.data) : nullptr), gvnValue(i.gvnValue), exp(i.exp) { }
+ Info(Data * _data = nullptr) : R(false), W(false), O(false), isint(false), local(Local::INFO_TRUE), cleared(false), exists(true), data(_data), exp(nullptr) { }
+ Info(const Info & i) : R(i.R), W(i.W), O(i.O), isint(i.isint), local(i.local), cleared(i.cleared), exists(i.exists), constant(i.constant), type(i.type), data(i.data ? new Data(*i.data) : nullptr), exp(i.exp) { }
inline void merge(Info & info)
{
}
cleared = cleared && info.cleared;
exists = exists || info.exists;
- knownValue = knownValue && info.knownValue && value == info.value;
+ constant.merge(info.constant);
+ //knownValue = knownValue && info.knownValue && value == info.value;
type.merge(info.type);
data->valid = data->same(info.data);
}
data->add(sym);
}
- inline void setValue(double _value)
- {
- knownValue = true;
- value = _value;
- }
-
- inline void setValue(GVN::Value * _value)
+ inline ConstantValue & getConstant()
{
- gvnValue = _value;
+ return constant;
}
- inline GVN::Value * getValue()
+ inline const ConstantValue & getConstant() const
{
- return gvnValue;
+ return constant;
}
- inline bool asDouble(double & _value) const
+ inline ConstantValue & setConstant(ConstantValue & val)
{
- if (knownValue)
- {
- _value = value;
- return true;
- }
-
- return false;
+ constant = val;
+ return constant;
}
inline bool isknown() const
<< L" - int:" << (info.isint ? L"T" : L"F")
<< L" - local:" << (info.local == Local::INFO_TRUE ? L"T" : (info.local == Local::INFO_FALSE ? L"F" : L"U"))
<< L" - cleared:" << (info.cleared ? L"T" : L"F")
- << L" - exists:" << (info.exists ? L"T" : L"F");
-
- if (info.knownValue)
- {
- out << L" - value:" << info.value;
- }
-
- if (info.gvnValue)
- {
- out << L" - GVN value:" << *info.gvnValue;
- }
+ << L" - exists:" << (info.exists ? L"T" : L"F")
+ << L" - constant:" << info.constant;
out << L" - data:";
if (info.data)
#include <sstream>
#include <string>
#include <unordered_set>
+#include <vector>
#include "core_math.h"
#include "tools.hxx"
public:
/** \brief Return the name of the type name (read only). */
- const std::wstring getValue() const
+ const std::wstring & getValue() const
{
return _value;
}
{
if (lhs == 1)
{
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setValue(0, tools::IntType::UNSIGNED);
+ Result & res = e.getDecorator().setResult(type);
+ res.getConstant().set(0.);
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"argn"));
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(res);
return true;
}
return false;
}
- enum Kind
+ enum Kind
{
LHS, RHS, LHSRHS
} kind;
case RHS:
{
const unsigned int val = kind == LHS ? fblock->getLHS() : fblock->getRHS();
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setValue(val, tools::IntType::UNSIGNED);
+ Result & res = e.getDecorator().setResult(type);
+ res.getConstant().set(val);
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"argn"));
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(res);
}
case LHSRHS:
{
const unsigned int flhs = fblock->getLHS();
const unsigned int frhs = fblock->getRHS();
mlhs.emplace_back(type);
- mlhs.back().setValue(flhs, tools::IntType::UNSIGNED);
+ mlhs.back().getConstant().set((double)flhs);
mlhs.emplace_back(type);
- mlhs.back().setValue(frhs, tools::IntType::UNSIGNED);
+ mlhs.back().getConstant().set((double)frhs);
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"argn"));
}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "ConstantValue.hxx"
+
+namespace analysis
+{
+
+void ConstantValue::merge(const ConstantValue & cv)
+{
+ if (kind == cv.kind)
+ {
+ switch (kind)
+ {
+ case DOUBLE:
+ merge<double>(cv);
+ break;
+ case GVNVAL:
+ merge<GVN::Value *>(cv);
+ break;
+ case STRING:
+ merge<const std::wstring *>(cv);
+ break;
+ case BOOLEAN:
+ merge<bool>(cv);
+ break;
+ case COMPLEX:
+ //merge<const std::complex<double> &>(cv);
+ break;
+ default:
+ break;
+ }
+ }
+ else if (kind == GVNVAL && cv.kind == DOUBLE)
+ {
+ if (!get<GVN::Value *>()->poly->isConstant(cv.get<double>()))
+ {
+ kind = UNKNOWN;
+ }
+ }
+ else if (kind == DOUBLE && cv.kind == GVNVAL)
+ {
+ if (cv.get<GVN::Value *>()->poly->isConstant(get<double>()))
+ {
+ set(cv.get<GVN::Value *>());
+ }
+ else
+ {
+ kind = UNKNOWN;
+ }
+ }
+ else
+ {
+ kind = UNKNOWN;
+ }
+}
+}
namespace analysis
{
- bool DiagAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool DiagAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs > 1)
{
- if (lhs > 1)
- {
- return false;
- }
+ return false;
+ }
- const ast::exps_t args = e.getArgs();
- const std::size_t size = args.size();
- if (size != 1 && size != 2)
- {
- return false;
- }
+ const ast::exps_t args = e.getArgs();
+ const std::size_t size = args.size();
+ if (size != 1 && size != 2)
+ {
+ return false;
+ }
- ast::Exp * first = *args.begin();
- ast::Exp * second = size == 2 ? *std::next(args.begin()) : nullptr;
- int index = 0;
+ ast::Exp * first = *args.begin();
+ ast::Exp * second = size == 2 ? *std::next(args.begin()) : nullptr;
+ int index = 0;
+
+ first->accept(visitor);
+ Result R1 = visitor.getResult();
+ if (!R1.getType().ismatrix())
+ {
+ return false;
+ }
- first->accept(visitor);
- Result R1 = visitor.getResult();
- if (!R1.getType().ismatrix())
+ if (second)
+ {
+ second->accept(visitor);
+ Result & R2 = visitor.getResult();
+ double val;
+ if (R2.getConstant().getDblValue(val))
{
- return false;
+ index = tools::cast<int>(val);
}
-
- if (second)
+ else
{
- second->accept(visitor);
- Result & R2 = visitor.getResult();
- double val;
- if (R2.getValue(val))
- {
- index = tools::cast<int>(val);
- }
- else
- {
- return false;
- }
+ return false;
}
+ }
- bool isOneDim = false;
- GVN::Value * dim;
- TIType & type = R1.getType();
- GVN::Value * ONE = visitor.getGVN().getValue(1.);
- isOneDim = visitor.getCM().check(ConstraintManager::EQUAL, type.rows.getValue(), ONE);
+ bool isOneDim = false;
+ GVN::Value * dim;
+ TIType & type = R1.getType();
+ GVN::Value * ONE = visitor.getGVN().getValue(1.);
+ isOneDim = visitor.getCM().check(ConstraintManager::EQUAL, type.rows.getValue(), ONE);
+ if (isOneDim)
+ {
+ dim = type.cols.getValue();
+ }
+ else
+ {
+ isOneDim = visitor.getCM().check(ConstraintManager::EQUAL, type.cols.getValue(), ONE);
if (isOneDim)
{
- dim = type.cols.getValue();
- }
- else
- {
- isOneDim = visitor.getCM().check(ConstraintManager::EQUAL, type.cols.getValue(), ONE);
- if (isOneDim)
- {
- dim = type.rows.getValue();
- }
+ dim = type.rows.getValue();
}
+ }
- if (isOneDim)
+ if (isOneDim)
+ {
+ SymbolicDimension sdim = index == 0 ? SymbolicDimension(&visitor.getGVN(), dim) : SymbolicDimension(&visitor.getGVN(), visitor.getGVN().getValue(OpValue::Kind::PLUS, *dim, *visitor.getGVN().getValue(std::abs(index))));
+ TIType resT(visitor.getGVN(), R1.getType().type, sdim, sdim);
+ e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
+ }
+ else
+ {
+ bool res = visitor.getCM().check(ConstraintManager::EQUAL, type.rows.getValue(), type.cols.getValue());
+ if (res)
{
- SymbolicDimension sdim = index == 0 ? SymbolicDimension(&visitor.getGVN(), dim) : SymbolicDimension(&visitor.getGVN(), visitor.getGVN().getValue(OpValue::Kind::PLUS, *dim, *visitor.getGVN().getValue(std::abs(index))));
- TIType resT(visitor.getGVN(), R1.getType().type, sdim, sdim);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
+ SymbolicDimension dimONE(visitor.getGVN(), 1.);
+ TIType resT(visitor.getGVN(), R1.getType().type, type.rows, dimONE);
+ e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
}
else
{
- bool res = visitor.getCM().check(ConstraintManager::EQUAL, type.rows.getValue(), type.cols.getValue());
+ res = visitor.getCM().check(ConstraintManager::GREATER, type.rows.getValue(), type.cols.getValue());
if (res)
{
- SymbolicDimension dimONE(visitor.getGVN(), 1.);
- TIType resT(visitor.getGVN(), R1.getType().type, type.rows, dimONE);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
+ if (index == 0)
+ {
+ SymbolicDimension dimONE(visitor.getGVN(), 1);
+ TIType resT(visitor.getGVN(), R1.getType().type, type.cols, dimONE);
+ e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
+ }
+ else
+ {
+ return false;
+ }
}
else
{
- res = visitor.getCM().check(ConstraintManager::GREATER, type.rows.getValue(), type.cols.getValue());
+ res = visitor.getCM().check(ConstraintManager::GREATER, type.cols.getValue(), type.rows.getValue());
if (res)
{
if (index == 0)
{
SymbolicDimension dimONE(visitor.getGVN(), 1);
- TIType resT(visitor.getGVN(), R1.getType().type, type.cols, dimONE);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
+ TIType resT(visitor.getGVN(), R1.getType().type, type.rows, dimONE);
+ e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
}
else
{
}
else
{
- res = visitor.getCM().check(ConstraintManager::GREATER, type.cols.getValue(), type.rows.getValue());
- if (res)
- {
- if (index == 0)
- {
- SymbolicDimension dimONE(visitor.getGVN(), 1);
- TIType resT(visitor.getGVN(), R1.getType().type, type.rows, dimONE);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
+ return false;
}
}
}
+ }
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(e.getDecorator().res);
- return true;
- }
+ return true;
+}
}
const MultivariateMonomial & m1 = *poly.polynomial.begin();
const MultivariateMonomial & m2 = *std::next(poly.polynomial.begin());
- if ((m1.coeff == 1 && m2.coeff == -1) || (m1.coeff == -1 && m2.coeff == 1) && (m1.monomial.size() == 1 && m2.monomial.size() == 1))
+ if (((m1.coeff == 1 && m2.coeff == -1) || (m1.coeff == -1 && m2.coeff == 1)) && (m1.monomial.size() == 1 && m2.monomial.size() == 1))
{
// We have a polynomial P such as P(X,Y)=X-Y
GVN::Value & x = *values[m1.monomial.begin()->var];
SymbolicDimension & rows = res.getType().rows;
SymbolicDimension & cols = res.getType().cols;
SymbolicDimension prod = rows * cols;
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setGVNValue(prod.getValue());
- e.getDecorator().setCall(Call(Call::IDENTITY, type, L"length"));
- visitor.setResult(e.getDecorator().res);
+ Result & _res = e.getDecorator().setResult(type);
+ _res.getConstant().set(prod.getValue());
+ e.getDecorator().setCall(Call(Call::IDENTITY, type, L"length"));
+ visitor.setResult(_res);
return true;
}
}
SymbolicDimension rows;
SymbolicDimension cols;
- if (R2.getValue(val))
+ if (R2.getConstant().getDblValue(val))
{
const int nrows = tools::cast<int>(val);
if (nrows <= 0)
rows = SymbolicDimension(visitor.getGVN(), nrows);
}
}
- else if (GVN::Value * gvnValue = R2.getGVNValue())
+ else if (GVN::Value * gvnValue = R2.getConstant().getGVNValue())
{
if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
{
return false;
}
- if (R3.getValue(val))
+ if (R3.getConstant().getDblValue(val))
{
const int ncols = tools::cast<int>(val);
if (ncols <= 0)
cols = SymbolicDimension(visitor.getGVN(), ncols);
}
}
- else if (GVN::Value * gvnValue = R3.getGVNValue())
+ else if (GVN::Value * gvnValue = R3.getConstant().getGVNValue())
{
if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
{
}
TIType resT(visitor.getGVN(), R1.getType().type, rows, cols);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
- visitor.setResult(e.getDecorator().res);
-
+ Result & _res = e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
+ visitor.setResult(_res);
return true;
}
}
SymbolicDimension rows, cols;
bool empty = false;
- if (R1.getValue(val))
+ if (R1.getConstant().getDblValue(val))
{
const int nrows = tools::cast<int>(val);
if (nrows <= 0)
rows = SymbolicDimension(visitor.getGVN(), nrows);
}
}
- else if (GVN::Value * gvnValue = R1.getGVNValue())
+ else if (GVN::Value * gvnValue = R1.getConstant().getGVNValue())
{
rows.setValue(gvnValue);
rows.setGVN(&visitor.getGVN());
if (!empty)
{
- if (R2.getValue(val))
+ if (R2.getConstant().getDblValue(val))
{
const int ncols = tools::cast<int>(val);
if (ncols <= 0)
cols = SymbolicDimension(visitor.getGVN(), ncols);
}
}
- else if (GVN::Value * gvnValue = R2.getGVNValue())
+ else if (GVN::Value * gvnValue = R2.getConstant().getGVNValue())
{
cols.setValue(gvnValue);
cols.setGVN(&visitor.getGVN());
if (empty)
{
- e.getDecorator().res = Result(TIType(visitor.getGVN(), TIType::EMPTY));
+ e.getDecorator().setResult(TIType(visitor.getGVN(), TIType::EMPTY));
}
else
{
return false;
}
TIType resT(visitor.getGVN(), TIType::DOUBLE, rows, cols);
- e.getDecorator().res = Result(resT, visitor.getTemp().add(resT));
+ e.getDecorator().setResult(Result(resT, visitor.getTemp().add(resT)));
}
visitor.setResult(e.getDecorator().res);
case ROWS:
{
SymbolicDimension & rows = res.getType().rows;
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setGVNValue(rows.getValue());
+ Result & _res = e.getDecorator().setResult(type);
+ _res.getConstant().set(rows.getValue());
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"size"));
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(_res);
break;
}
case COLS:
{
SymbolicDimension & cols = res.getType().cols;
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setGVNValue(cols.getValue());
+ Result & _res = e.getDecorator().setResult(type);
+ _res.getConstant().set(cols.getValue());
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"size"));
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(_res);
break;
}
case ROWSTIMESCOLS:
SymbolicDimension & rows = res.getType().rows;
SymbolicDimension & cols = res.getType().cols;
SymbolicDimension prod = rows * cols;
- e.getDecorator().res = Result(type);
- e.getDecorator().res.setGVNValue(prod.getValue());
+ Result & _res = e.getDecorator().setResult(type);
+ _res.getConstant().set(prod.getValue());
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"size"));
- visitor.setResult(e.getDecorator().res);
+ visitor.setResult(_res);
break;
}
case ROWSCOLS:
mlhs.clear();
mlhs.reserve(2);
mlhs.emplace_back(type);
- mlhs.back().setGVNValue(rows.getValue());
+ mlhs.back().getConstant().set(rows.getValue());
mlhs.emplace_back(type);
- mlhs.back().setGVNValue(cols.getValue());
+ mlhs.back().getConstant().set(cols.getValue());
e.getDecorator().setCall(Call(Call::IDENTITY, type, L"size"));
break;
switch (type)
{
case 0:
- e.getDecorator().res = Result(TIType(dm.getGVN(), TIType::EMPTY), -1);
+ e.getDecorator().setResult(Result(TIType(dm.getGVN(), TIType::EMPTY), -1));
break;
case 1:
- e.getDecorator().res = Result(TIType(dm.getGVN(), TIType::DOUBLE), -1);
+ e.getDecorator().setResult(Result(TIType(dm.getGVN(), TIType::DOUBLE), -1));
break;
case 2:
{
{
out = start;
}
- e.getDecorator().res = Result(T, temp.add(T));
+ e.getDecorator().setResult(Result(T, temp.add(T)));
break;
}
default:
if (!AnalysisVisitor::asDouble(e.getStep(), step) || (step != -1 && step != 1))
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1);
- setResult(e.getDecorator().res);
-
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
return;
}
if (!Rstart.getType().isscalar())
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1);
- setResult(e.getDecorator().res);
-
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
return;
}
- if (Rstart.getValue(start))
+ if (Rstart.getConstant().getDblValue(start))
{
- if (Rstart.getIntType() == tools::NOTANINT)
+ if (tools::getIntType(start) == tools::NOTANINT)
{
gvnStart = getGVN().getValue((double)tools::cast<int>(start + step));
}
}
else
{
- gvnStart = Rstart.getGVNValue();
+ gvnStart = Rstart.getConstant().getGVNValue();
if (!gvnStart)
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1);
- setResult(e.getDecorator().res);
-
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
return;
}
}
Result & Rend = getResult();
GVN::Value * gvnEnd;
- if (Rend.getValue(end))
+ if (Rend.getConstant().getDblValue(end))
{
- if (Rend.getIntType() == tools::NOTANINT)
+ if (tools::getIntType(end) == tools::NOTANINT)
{
gvnEnd = getGVN().getValue((double)tools::cast<int>(end - step));
}
}
else
{
- gvnEnd = Rend.getGVNValue();
+ gvnEnd = Rend.getConstant().getGVNValue();
if (!gvnEnd)
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1);
- setResult(e.getDecorator().res);
-
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
return;
}
}
if (res)
{
TIType type(getGVN(), TIType::DOUBLE, ONE, SymbolicDimension(getGVN(), v));
- e.getDecorator().res = Result(type);
+ e.getDecorator().setResult(type);
}
else
{
- e.getDecorator().res = Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1);
- setResult(e.getDecorator().res);
-
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
return;
}
}
// ============================================================================
// <-- JVM NOT MANDATORY -->
function y=test1(a, b)
- y = a+b;
+ y = a+b;
endfunction
a = 12;
b = ones(13, 17);
assert_checkequal(out.rows, 12);
assert_checkequal(out.cols, 11);
function y = test2(a, b, c)
- y = [a b;c]
+ y = [a b;c]
endfunction
a = 1:3;
b = 1:7;
assert_checkequal(out.rows, 3);
assert_checkequal(out.cols, 10);
function y = test3(a, b, c)
- row = size(a, "r");
- col = size(a, "c");
- a = matrix(a, col, row);
- [row, col] = size(b);
- b = matrix(b, col, row);
- y = (a .*. b) * c'
+ row = size(a, "r");
+ col = size(a, "c");
+ a = matrix(a, col, row);
+ [row, col] = size(b);
+ b = matrix(b, col, row);
+ y = (a .*. b) * c'
endfunction
a = ones(2, 4);
b = ones(5, 9);
assert_checkequal(out.rows, %nan);
assert_checkequal(out.cols, %nan);
function y = test4(a, b, c)
- y = test1(a, b) * test2(a, b, c)
+ y = test1(a, b) * test2(a, b, c)
endfunction
a = ones(5, 8);
b = ones(5, 8);