MCPcopy Create free account
hub / github.com/argotorg/solidity / TypeSystem

Class TypeSystem

libsolidity/experimental/ast/TypeSystem.h:100–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98};
99
100class TypeSystem
101{
102public:
103 struct TypeConstructorInfo
104 {
105 std::string name;
106 std::string canonicalName;
107 std::vector<Arity> arities;
108 Declaration const* typeDeclaration = nullptr;
109 size_t arguments() const
110 {
111 solAssert(!arities.empty());
112 return arities.front().argumentSorts.size();
113 }
114 };
115 struct TypeClassInfo
116 {
117 Type typeVariable;
118 std::string name;
119 Declaration const* classDeclaration = nullptr;
120 };
121 TypeSystem();
122 TypeSystem(TypeSystem const&) = delete;
123 TypeSystem const& operator=(TypeSystem const&) = delete;
124 Type type(PrimitiveType _typeConstructor, std::vector<Type> _arguments) const
125 {
126 return type(m_primitiveTypeConstructors.at(_typeConstructor), std::move(_arguments));
127 }
128 Type type(TypeConstructor _typeConstructor, std::vector<Type> _arguments) const;
129 std::string typeName(TypeConstructor _typeConstructor) const
130 {
131 // TODO: proper error handling
132 return m_typeConstructors.at(_typeConstructor.m_index).name;
133 }
134 std::string canonicalName(TypeConstructor _typeConstructor) const
135 {
136 // TODO: proper error handling
137 return m_typeConstructors.at(_typeConstructor.m_index).canonicalName;
138 }
139 TypeConstructor declareTypeConstructor(std::string _name, std::string _canonicalName, size_t _arguments, Declaration const* _declaration);
140 TypeConstructor constructor(PrimitiveType _type) const
141 {
142 return m_primitiveTypeConstructors.at(_type);
143 }
144 TypeClass primitiveClass(PrimitiveClass _class) const
145 {
146 return m_primitiveTypeClasses.at(_class);
147 }
148 size_t constructorArguments(TypeConstructor _typeConstructor) const
149 {
150 // TODO: error handling
151 return m_typeConstructors.at(_typeConstructor.m_index).arguments();
152 }
153 TypeConstructorInfo const& constructorInfo(TypeConstructor _typeConstructor) const
154 {
155 // TODO: error handling
156 return m_typeConstructors.at(_typeConstructor.m_index);
157 }

Callers

nothing calls this directly

Calls 2

constructorFunction · 0.85
atMethod · 0.80

Tested by

no test coverage detected