Commits (12)
......@@ -120,7 +120,7 @@ enum BasicTypes
////////////////////////////////////////////////////////////////////////////////
enum RegRealativeIds
enum RegRelativeIds
{
rriInstructionPointer,
rriStackFrame,
......@@ -205,7 +205,7 @@ public:
virtual bool isVirtualBaseClass() = 0;
virtual bool isVirtual() = 0;
virtual unsigned long getRegisterId() = 0;
virtual unsigned long getRegRealativeId() = 0; // <- RegRealativeId
virtual unsigned long getRegRelativeId() = 0; // <- RegRelativeId
virtual SymbolPtr getObjectPointerType() = 0; // "this" for method
virtual unsigned long getCallingConvention() = 0; // <- CallingConventionType
virtual SymbolPtr getClassParent() = 0; // "this" for method
......
......@@ -182,6 +182,7 @@ class TypeInfoProvider
public:
virtual TypeInfoPtr getTypeByName(const std::wstring& name) = 0;
virtual TypeInfoEnumeratorPtr getTypeEnumerator(const std::wstring& mask = L"") = 0;
virtual std::wstring makeTypeName(const std::wstring& typeName, const std::wstring& qualified, bool const) = 0;
};
class TypeInfoEnumerator {
......
......@@ -2,6 +2,7 @@
#include <string>
#include <list>
#include <map>
#pragma pack( push, 4 )
......@@ -448,6 +449,7 @@ extern TemplateStruct<TemplateStruct<int>[4]> g_template4;
////////////////////////////////////////////////////////////////////////////////
extern std::list<int> g_stdIntList;
extern std::map<int, TemplateStruct<int> > g_stdMap;
template<typename T>
struct TestStructTemplate
......
This diff is collapsed.
#pragma once
#include "exprparser.h"
#include <kdlib/typeinfo.h>
namespace kdlib {
bool isBaseTypeKeyWord(const clang::Token& token);
bool isStandardIntType(const clang::Token& token);
bool isInt64KeyWord(const clang::Token& token);
namespace parser {
class BaseTypeMatcher : public Matcher
{
public:
MatchResult match(const TokenRange& matchRange);
std::string getTypeName() const
{
return m_typeName;
}
TypeInfoPtr getBaseType() const
{
return m_typeInfo;
}
bool isConst() const
{
return m_const;
}
private:
bool m_const;
TypeInfoPtr m_typeInfo;
std::string m_typeName;
};
}
}
\ No newline at end of file
......@@ -868,6 +868,23 @@ TypeInfoEnumeratorPtr TypeInfoProviderClang::getTypeEnumerator(const std::wstrin
///////////////////////////////////////////////////////////////////////////////
std::wstring TypeInfoProviderClang::makeTypeName(const std::wstring& typeName, const std::wstring& typeQualifier, bool isConst)
{
std::wstringstream wstr;
if (isConst)
wstr << L"const ";
wstr << typeName;
if (!typeQualifier.empty())
wstr << L' ' << typeQualifier;
return wstr.str();
}
///////////////////////////////////////////////////////////////////////////////
TypeInfoProviderClangEnum::TypeInfoProviderClangEnum(const std::wstring& mask, const boost::shared_ptr<TypeInfoProviderClang>& clangProvider )
{
m_index = 0;
......
......@@ -388,9 +388,11 @@ public:
private:
virtual TypeInfoPtr getTypeByName(const std::wstring& name);
TypeInfoPtr getTypeByName(const std::wstring& name) override;
virtual TypeInfoEnumeratorPtr getTypeEnumerator(const std::wstring& mask);
TypeInfoEnumeratorPtr getTypeEnumerator(const std::wstring& mask) override;
std::wstring makeTypeName(const std::wstring& typeName, const std::wstring& typeQualifier, bool isConst) override;
private:
......
......@@ -34,8 +34,6 @@ kdlib::TypeInfoPtr getStandardIntType(const std::string& name);
bool isBinOperation(const clang::Token& token);
bool isInt64KeyWord(const clang::Token& token);
///////////////////////////////////////////////////////////////////////////////
TypedValue evalExpr(const std::wstring& expr, const ScopePtr& scope, const TypeInfoProviderPtr& typeInfoProvider)
......@@ -207,93 +205,6 @@ TypeInfoPtr evalType(const std::string& expr, const TypeInfoProviderPtr typeInfo
///////////////////////////////////////////////////////////////////////////////
std::list<std::string> getTempalteArgs(const std::string& expr)
{
auto preprocessorOptions = std::make_shared<clang::PreprocessorOptions>();
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagnosticIDs(new clang::DiagnosticIDs());
auto diagnosticOptions = new clang::DiagnosticOptions();
auto diagnosticConsumer = new clang::IgnoringDiagConsumer();
clang::DiagnosticsEngine diagnosticEngine(diagnosticIDs, diagnosticOptions, diagnosticConsumer);
clang::LangOptions langOptions;
llvm::IntrusiveRefCntPtr<clang::vfs::InMemoryFileSystem> memoryFileSystem(new clang::vfs::InMemoryFileSystem());
memoryFileSystem->addFile("<input>", 0, llvm::MemoryBuffer::getMemBuffer(expr.c_str()));
clang::FileSystemOptions fileSystemOptions;
clang::FileManager fileManager(fileSystemOptions, memoryFileSystem);
clang::SourceManager sourceManager(diagnosticEngine, fileManager);
const clang::FileEntry *pFile = fileManager.getFile("<input>");
clang::FileID fileID = sourceManager.getOrCreateFileID(pFile, clang::SrcMgr::C_User);
sourceManager.setMainFileID(fileID);
clang::MemoryBufferCache memoryBufferCache;
auto headerSearchOptions = std::make_shared<clang::HeaderSearchOptions>();
auto targetOptions = std::make_shared<clang::TargetOptions>();
targetOptions->Triple = llvm::sys::getDefaultTargetTriple();
clang::TargetInfo* targetInfo = clang::TargetInfo::CreateTargetInfo(diagnosticEngine, targetOptions);
clang::HeaderSearch headerSearch(headerSearchOptions, sourceManager, diagnosticEngine, langOptions, targetInfo);
clang::CompilerInstance compilerInstance;
clang::Preprocessor preprocessor(
preprocessorOptions,
diagnosticEngine,
langOptions,
sourceManager,
memoryBufferCache,
headerSearch,
compilerInstance
);
preprocessor.Initialize(*targetInfo);
preprocessor.EnterMainSourceFile();
diagnosticConsumer->BeginSourceFile(langOptions, &preprocessor);
clang::Token token;
std::list<clang::Token> tokens;
do {
preprocessor.Lex(token);
if (diagnosticEngine.hasErrorOccurred())
{
NOT_IMPLEMENTED();
}
tokens.push_back(token);
} while (!token.is(clang::tok::eof));
diagnosticConsumer->EndSourceFile();
TypeEval exprEval(getDefaultScope(), getDefaultTypeInfoProvider(), &tokens);
return exprEval.getTemplateArgList();
}
///////////////////////////////////////////////////////////////////////////////
std::list<std::wstring> getTempalteArgs(const std::wstring& typeName)
{
const std::list<std::string>& argList = getTempalteArgs(wstrToStr(typeName));
std::list<std::wstring> wargLst;
std::for_each(argList.begin(), argList.end(), [&wargLst](const auto& arg) {
wargLst.push_back(strToWStr(arg));
});
return wargLst;
}
///////////////////////////////////////////////////////////////////////////////
ExprEval::ExprEval(const ScopePtr& scope,
const TypeInfoProviderPtr& typeInfoProvider,
std::list<clang::Token>* tokens,
......@@ -849,14 +760,35 @@ std::string getTypeModifierRecursive(const parser::ComplexMatcher& matcher)
if (matcher.isPointer())
{
bool needSpace = false;
for (auto p : matcher.getPointerMatcher().getPointerMatchers())
{
if (needSpace)
{
sstr << ' ';
needSpace = false;
}
sstr << '*';
if (p.isConst())
{
sstr << "const";
needSpace = true;
}
}
}
if (matcher.isReference())
{
if (matcher.getRefMatcher().isLvalue())
sstr << '&';
else
sstr << "&&";
}
if (matcher.isNestedMatcher())
{
sstr << '(' << getTypeModifierRecursive(matcher.getNestedMatcher().getInnerMatcher()) << ')';
}
}
if (matcher.isArray())
{
......@@ -884,15 +816,10 @@ TypeInfoPtr TypeEval::getResult()
{
using namespace parser;
std::list<clang::Token> tokens;
std::copy_if(m_tokens->cbegin(), m_tokens->cend(), std::back_inserter(tokens), [](auto& token){
return !token.is(clang::tok::kw_const);
});
TypeMatcher typeMatcher;
QualifiedTypeMatcher typeMatcher;
auto matcher = all_of(typeMatcher, token_is(m_endToken));
auto matchResult = matcher.match(std::make_pair(tokens.cbegin(), tokens.cend()));
auto matchResult = matcher.match(std::make_pair(m_tokens->cbegin(), m_tokens->cend()));
if (!matchResult.isMatched())
throw ExprException(L"error syntax");
......@@ -901,11 +828,11 @@ TypeInfoPtr TypeEval::getResult()
if (typeMatcher.isBasedType())
{
typeInfo = getBaseType();
typeInfo = typeMatcher.getBaseTypeMatcher().getBaseType();
}
else if (typeMatcher.isStandardIntType())
{
typeInfo = getStandardIntType();
typeInfo = getStandardIntType(typeMatcher.getStandardIntMatcher());
}
else if (typeMatcher.isCustomType())
{
......@@ -924,8 +851,7 @@ TypeInfoPtr TypeEval::getResult()
typeInfo = applyComplexModifierRecursive(typeMatcher.getComplexMather(), typeInfo);
}
tokens.erase(matchResult.begin(), matchResult.end());
*m_tokens = tokens;
m_tokens->erase(matchResult.begin(), matchResult.end());
return typeInfo;
}
......@@ -936,15 +862,10 @@ std::list<std::string> TypeEval::getTemplateArgList()
{
using namespace parser;
std::list<clang::Token> tokens;
std::copy_if(m_tokens->cbegin(), m_tokens->cend(), std::back_inserter(tokens), [](auto& token) {
return !token.is(clang::tok::kw_const);
});
TypeMatcher typeMatcher;
auto matcher = all_of(typeMatcher, token_is(m_endToken));
auto matchResult = matcher.match(std::make_pair(tokens.cbegin(), tokens.cend()));
auto matchResult = matcher.match(std::make_pair(m_tokens->cbegin(), m_tokens->cend()));
if (!matchResult.isMatched())
throw ExprException(L"error syntax");
......@@ -956,59 +877,33 @@ std::list<std::string> TypeEval::getTemplateArgList()
if (customMatcher.isTemplate())
{
const auto& argList = customMatcher.getTemplateMatcher().getTemplateArgs();
std::list<std::string> argStrList;
for (auto& arg : argList)
{
if (arg.isType())
{
argStrList.push_back(getTypeName(arg.getTypeMatcher()));
}
else if (arg.isExpression())
{
auto value = ExprEval2(m_scope, m_typeInfoProvider, arg.getExpressionMatcher().getMatchResult().getMatchedRange()).getResult();
argStrList.push_back(std::to_string(value.getValue().asLongLong()));
}
else
{
throw ExprException(L"error syntax");
}
}
const auto& argListMatcher = customMatcher.getTemplateMatcher().getTemplateArgs();
return argStrList;
return getTemplateArgList(argListMatcher);
}
if (customMatcher.isNestedTemplate())
{
const auto& templateMatcher = customMatcher.getNestedTemplateMatcher();
const auto& argList = templateMatcher.getTemplateArgs1();
const auto& argListMatcher = templateMatcher.getTemplateArgs1();
std::list<std::string> argStrList;
for (auto& arg : argList)
{
if (arg.isType())
{
argStrList.push_back(getTypeName(arg.getTypeMatcher()));
}
else if (arg.isExpression())
{
auto value = ExprEval2(m_scope, m_typeInfoProvider, arg.getExpressionMatcher().getMatchResult().getMatchedRange()).getResult();
argStrList.push_back(std::to_string(value.getValue().asLongLong()));
}
else
{
throw ExprException(L"error syntax");
}
}
std::list<std::string> argStrList = getTemplateArgList(argListMatcher);
std::string templateName = templateMatcher.getNestedTemplateName();
templateName += '<';
templateName += getTemplateArgs(templateMatcher.getTemplateArgs2());
const auto& nestedArgList = getTemplateArgList(templateMatcher.getTemplateArgs2());
std::string argsStr;
for (const auto& arg : nestedArgList)
{
if (!argsStr.empty())
argsStr += ',';
argsStr += arg;
}
templateName += argsStr;
templateName += '>';
......@@ -1022,23 +917,20 @@ std::list<std::string> TypeEval::getTemplateArgList()
///////////////////////////////////////////////////////////////////////////////
std::string TypeEval::getTemplateArgs(const parser::ListMatcher<parser::TemplateArgMatcher>& argList)
std::list<std::string> TypeEval::getTemplateArgList(const parser::ListMatcher<parser::TemplateArgMatcher>& argList)
{
std::string argsStr;
std::list<std::string> argStrList;
for (auto& arg : argList)
{
if (!argsStr.empty())
argsStr += ',';
if (arg.isType())
{
argsStr += getTypeName(arg.getTypeMatcher());
argStrList.push_back(getTypeName(arg.getTypeMatcher()));
}
else if (arg.isExpression())
{
auto value = ExprEval2(m_scope, m_typeInfoProvider, arg.getExpressionMatcher().getMatchResult().getMatchedRange()).getResult();
argsStr += std::to_string(value.getValue().asLongLong());
argStrList.push_back(std::to_string(value.getValue().asLongLong()));
}
else
{
......@@ -1046,6 +938,23 @@ std::string TypeEval::getTemplateArgs(const parser::ListMatcher<parser::Template
}
}
return argStrList;
}
///////////////////////////////////////////////////////////////////////////////
std::string TypeEval::getTemplateArgs(const parser::ListMatcher<parser::TemplateArgMatcher>& argListMatcher)
{
const auto& argList = getTemplateArgList(argListMatcher);
std::string argsStr;
for (const auto& arg : argList)
{
if (!argsStr.empty())
argsStr += ',';
argsStr += arg;
}
return argsStr;
}
......@@ -1054,7 +963,7 @@ std::string TypeEval::getTemplateArgs(const parser::ListMatcher<parser::Template
std::string TypeEval::getTemplateName(const parser::TemplateMatcher& templateMatcher)
{
std::string templateName = getTemplateArgs(templateMatcher.getTemplateArgs());
templateName.insert(templateName.begin(), '<');
if (templateName.back() == '>')
templateName.insert(templateName.end(), ' ');
......@@ -1158,27 +1067,33 @@ TypeInfoPtr TypeEval::getCustomType(const parser::CustomTypeMatcher& customMatc
///////////////////////////////////////////////////////////////////////////////
std::string TypeEval::getTypeName(const parser::TypeMatcher& typeMatcher)
std::string TypeEval::getTypeName(const parser::QualifiedTypeMatcher& typeMatcher)
{
std::string typeName;
std::string typeName;
std::string typeQualifier;
if (typeMatcher.isBasedType())
{
typeName = getBaseTypeName(typeMatcher.getBaseTypeMatcher());
typeName = typeMatcher.getBaseTypeMatcher().getTypeName();
}
else
if (typeMatcher.isCustomType())
{
typeName = getCustomTypeName(typeMatcher.getCustomMatcher());
}
if (typeMatcher.isComplexType())
else
{
typeName += ' ';
typeName += getTypeModifierRecursive(typeMatcher.getComplexMather());
throw ExprException(L"error syntax");
}
return typeName;
if (typeMatcher.isComplexType())
{
typeQualifier = getTypeModifierRecursive(typeMatcher.getComplexMather());
}
auto fullTypeName = m_typeInfoProvider->makeTypeName(strToWStr(typeName), strToWStr(typeQualifier), typeMatcher.isConst());
return wstrToStr(fullTypeName);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -1224,182 +1139,10 @@ std::string TypeEval::getCustomTypeName(const parser::CustomTypeMatcher& customM
///////////////////////////////////////////////////////////////////////////////
std::string TypeEval::getBaseTypeName(const parser::BaseTypeMatcher& baseTypeMatcher)
{
if (baseTypeMatcher.getMatchResult().begin()->is(clang::tok::kw_void))
{
return "void";
}
std::unique_ptr<BaseTypeBuilder> baseTypeBuilder(new EmptyBaseTypeBuilder);
for (auto& token : baseTypeMatcher.getMatchResult())
{
if (token.is(clang::tok::kw_int))
{
baseTypeBuilder.reset(baseTypeBuilder->addInt());
}
else
if (token.is(clang::tok::kw_char))
{
baseTypeBuilder.reset(baseTypeBuilder->addChar());
}
else
if (token.is(clang::tok::kw_short))
{
baseTypeBuilder.reset(baseTypeBuilder->addShort());
}
else
if (token.is(clang::tok::kw_unsigned))
{
baseTypeBuilder.reset(baseTypeBuilder->addUnsigned());
}
else
if (token.is(clang::tok::kw_signed))
{
baseTypeBuilder.reset(baseTypeBuilder->addSigned());
}
else
if (token.is(clang::tok::kw_long))
{
baseTypeBuilder.reset(baseTypeBuilder->addLong());
}
else
if (isInt64KeyWord(token))
{
baseTypeBuilder.reset(baseTypeBuilder->addLong());
baseTypeBuilder.reset(baseTypeBuilder->addLong());
}
else
if (token.is(clang::tok::kw_float))
{
baseTypeBuilder.reset(baseTypeBuilder->addFloat());
}
else
if (token.is(clang::tok::kw_double))
{
baseTypeBuilder.reset(baseTypeBuilder->addDouble());
}
else
{
throw ExprException(L"error syntax");
}
}
return baseTypeBuilder->getTypeName();
}
///////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeEval::getBaseType()
{
if (m_tokens->front().is(clang::tok::kw_void))
{
m_tokens->pop_front();
return loadType(L"Void");
}
std::unique_ptr<BaseTypeBuilder> baseTypeBuilder(new EmptyBaseTypeBuilder);
while (true)
{
auto token = m_tokens->front();
if (token.is(m_endToken))
break;
if (token.is(clang::tok::kw_int))
{
baseTypeBuilder.reset(baseTypeBuilder->addInt());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_char))
{
baseTypeBuilder.reset(baseTypeBuilder->addChar());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_short))
{
baseTypeBuilder.reset(baseTypeBuilder->addShort());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_unsigned))
{
baseTypeBuilder.reset(baseTypeBuilder->addUnsigned());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_signed))
{
baseTypeBuilder.reset(baseTypeBuilder->addSigned());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_long))
{
baseTypeBuilder.reset(baseTypeBuilder->addLong());
m_tokens->pop_front();
continue;
}
if (isInt64KeyWord(token))
{
baseTypeBuilder.reset(baseTypeBuilder->addLong());
baseTypeBuilder.reset(baseTypeBuilder->addLong());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_float))
{
baseTypeBuilder.reset(baseTypeBuilder->addFloat());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_double))
{
baseTypeBuilder.reset(baseTypeBuilder->addDouble());
m_tokens->pop_front();
continue;
}
if (token.is(clang::tok::kw_const))
{
m_tokens->pop_front();
continue;
}
if (token.isOneOf(clang::tok::star, clang::tok::l_paren, clang::tok::l_square,
clang::tok::amp, clang::tok::ampamp))
break;
throw ExprException(L"error syntax");
}
return baseTypeBuilder->getResult();
}
///////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeEval::getStandardIntType()
TypeInfoPtr TypeEval::getStandardIntType(const parser::StandardIntMatcher& stdIntMatcher)
{
auto token = m_tokens->front();
m_tokens->pop_front();
assert(token.is(clang::tok::identifier));
std::string name(token.getIdentifierInfo()->getNameStart(), token.getLength());
auto& token = stdIntMatcher.getMatchResult().begin();
std::string name(token->getIdentifierInfo()->getNameStart(), token->getLength());
return kdlib::getStandardIntType(name);
}
......
......@@ -519,20 +519,19 @@ public:
private:
TypeInfoPtr getBaseType();
TypeInfoPtr getStandardIntType();
TypeInfoPtr getStandardIntType(const parser::StandardIntMatcher& stdIntMatcher);
std::string getTemplateArgs(const parser::ListMatcher<parser::TemplateArgMatcher>& argList);
std::list<std::string> getTemplateArgList(const parser::ListMatcher<parser::TemplateArgMatcher>& argList);
std::string getTemplateName(const parser::TemplateMatcher& templateMatcher);
std::string getNestedTemplateName(const parser::DoubleTemplateMatcher& templateMatcher);
std::string getTypeName(const parser::TypeMatcher& typeMatcher);
std::string getTypeName(const parser::QualifiedTypeMatcher& typeMatcher);
std::string getBaseTypeName(const parser::BaseTypeMatcher& baseTypeMatcher);
//std::string getBaseTypeName(const parser::BaseTypeMatcher& baseTypeMatcher);
std::string getCustomTypeName(const parser::CustomTypeMatcher& customMatcher);
......@@ -550,811 +549,6 @@ private:
///////////////////////////////////////////////////////////////////////////////
class BaseTypeBuilder {
public:
virtual TypeInfoPtr getResult() = 0;
virtual std::string getTypeName() = 0;
virtual BaseTypeBuilder* addChar() = 0;
virtual BaseTypeBuilder* addShort() = 0;
virtual BaseTypeBuilder* addInt() = 0;
virtual BaseTypeBuilder* addUnsigned() = 0;
virtual BaseTypeBuilder* addSigned() = 0;
virtual BaseTypeBuilder* addLong() = 0;
virtual BaseTypeBuilder* addFloat() = 0;
virtual BaseTypeBuilder* addDouble() = 0;
};
class DeclBaseTypeBuilder : public BaseTypeBuilder
{
BaseTypeBuilder* addChar() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addShort() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addInt() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addFloat() {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addDouble() {
throw ExprException(L"bad syntax");
}
};
class UnsignedCharBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt1B");
}
std::string getTypeName() override
{
return "unsigned char";
}
BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class SignedCharBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int1B");
}
std::string getTypeName() override
{
return "char";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class CharBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int1B");
}
std::string getTypeName() override
{
return "char";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedCharBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
throw new SignedCharBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class UnsignedShortBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt2B");
}
std::string getTypeName() override
{
return "unsigned short";
}
BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class SignedShortBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int2B");
}
std::string getTypeName() override
{
return "short";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class ShortBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int2B");
}
std::string getTypeName() override
{
return "short";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedShortBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedShortBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class UnsignedLongLongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt8B");
}
std::string getTypeName() override
{
return "unsigned long long";
}
BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class SignedLongLongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int8B");
}
std::string getTypeName() override
{
return "long long";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class UnsignedLongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt4B");
}
std::string getTypeName() override
{
return "unsigned long";
}
virtual BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongLongIntBaseTypeBuilder;
}
};
class SignedLongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "long";
}
virtual BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongLongIntBaseTypeBuilder;
}
};
class UnsignedIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt4B");
}
std::string getTypeName() override
{
return "unsigned int";
}
virtual BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongIntBaseTypeBuilder;
}
};
class SignedIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "int";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongIntBaseTypeBuilder;
}
};
class LongLongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int8B");
}
std::string getTypeName() override
{
return "long long";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedLongLongIntBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedLongLongIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class LongIntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "long";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedLongIntBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedLongIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
return new LongLongIntBaseTypeBuilder;
}
};
class IntBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "int";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedIntBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
return new LongIntBaseTypeBuilder;
}
};
class UnsignedLongLongBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt8B");
}
std::string getTypeName() override
{
return "unsigned long long";
}
virtual BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addInt() override {
return new UnsignedLongLongIntBaseTypeBuilder;
}
};
class SignedLongLongBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int8B");
}
std::string getTypeName() override
{
return "long long";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addInt() override {
return new UnsignedLongLongIntBaseTypeBuilder;
}
};
class UnsignedLongBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"UInt4B");
}
std::string getTypeName() override
{
return "unsigned long";
}
BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongLongBaseTypeBuilder;
}
BaseTypeBuilder* addInt() override {
return new UnsignedLongIntBaseTypeBuilder;
}
};
class SignedLongBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "long";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
BaseTypeBuilder* addLong() override {
return new SignedLongLongBaseTypeBuilder;
}
BaseTypeBuilder* addInt() override {
return new UnsignedLongIntBaseTypeBuilder;
}
};
class LongLongBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Int8B");
}
std::string getTypeName() override
{
return "long long";
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedLongLongBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedLongLongBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addInt() override {
return new LongLongIntBaseTypeBuilder;
}
};
class UnsignedBaseTypeBuilder : public DeclBaseTypeBuilder {
virtual TypeInfoPtr getResult() override {
return loadType(L"UInt4B");
}
std::string getTypeName() override
{
return "unsigned int";
}
virtual BaseTypeBuilder* addChar() override {
return new UnsignedCharBaseTypeBuilder;
}
virtual BaseTypeBuilder* addShort() override {
return new UnsignedShortBaseTypeBuilder;
}
virtual BaseTypeBuilder* addInt() override {
return new UnsignedIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
return new UnsignedLongBaseTypeBuilder;
}
BaseTypeBuilder* addUnsigned() override {
return this;
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
};
class SignedBaseTypeBuilder : public DeclBaseTypeBuilder {
virtual TypeInfoPtr getResult() override {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "int";
}
virtual BaseTypeBuilder* addChar() override {
return new SignedCharBaseTypeBuilder;
}
virtual BaseTypeBuilder* addShort() override {
return new SignedShortBaseTypeBuilder;
}
virtual BaseTypeBuilder* addInt() override {
return new SignedIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
return new SignedLongBaseTypeBuilder;
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
return this;
}
};
class LongDoubleBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Double");
}
std::string getTypeName() override
{
return "double";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class LongFloatBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Double");
}
std::string getTypeName() override
{
return "double";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
throw ExprException(L"bad syntax");
}
};
class LongBaseTypeBuilder : public DeclBaseTypeBuilder
{
virtual TypeInfoPtr getResult() {
return loadType(L"Int4B");
}
std::string getTypeName() override
{
return "long";
}
virtual BaseTypeBuilder* addInt() override {
return new LongIntBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {
return new LongLongBaseTypeBuilder;
}
BaseTypeBuilder* addUnsigned()override {
return new UnsignedLongBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedLongBaseTypeBuilder;
}
BaseTypeBuilder* addFloat() override {
return new LongFloatBaseTypeBuilder();
}
BaseTypeBuilder* addDouble() override {
return new LongDoubleBaseTypeBuilder();
}
};
class FloatBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Float");
}
std::string getTypeName() override
{
return "float";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
return new LongFloatBaseTypeBuilder();
}
};
class DoubleBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
return loadType(L"Double");
}
std::string getTypeName() override
{
return "double";
}
BaseTypeBuilder* addUnsigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addSigned() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addLong() override {
return new LongDoubleBaseTypeBuilder();
}
};
class EmptyBaseTypeBuilder : public DeclBaseTypeBuilder
{
TypeInfoPtr getResult() override {
throw ExprException(L"bad syntax");
}
std::string getTypeName() override {
throw ExprException(L"bad syntax");
}
BaseTypeBuilder* addInt() override {
return new IntBaseTypeBuilder;
}
BaseTypeBuilder* addChar() override {
return new CharBaseTypeBuilder;
}
BaseTypeBuilder* addShort() override {
return new ShortBaseTypeBuilder;
}
BaseTypeBuilder* addUnsigned() override {
return new UnsignedBaseTypeBuilder;
}
BaseTypeBuilder* addSigned() override {
return new SignedBaseTypeBuilder;
}
BaseTypeBuilder* addLong() override {