3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Random Shader Generator
5 * ----------------------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 *//*--------------------------------------------------------------------*/
26 #include "rsgDefs.hpp"
129 Token (const char* identifier);
133 Token (const Token& other);
137 inline bool operator== (Type type) const { return m_type == type; }
138 inline bool operator!= (Type type) const { return m_type != type; }
140 bool operator== (const Token& other) const;
141 bool operator!= (const Token& other) const;
143 Token& operator= (const Token& other);
145 inline Type getType (void) const { return m_type; }
147 const char* getIdentifier (void) const;
148 float getFloat (void) const;
149 int getInt (void) const;
150 bool getBool (void) const;
164 inline Token::Token (void)
167 m_arg.identifier = DE_NULL;
170 inline Token::Token (Type type)
173 DE_ASSERT(type != IDENTIFIER);
176 inline Token::Token (float value)
177 : m_type(FLOAT_LITERAL)
179 m_arg.floatValue = value;
182 inline Token::Token (int value)
183 : m_type(INT_LITERAL)
185 m_arg.intValue = value;
188 inline Token::Token (bool value)
189 : m_type(BOOL_LITERAL)
191 m_arg.boolValue = value;
194 inline bool Token::operator== (const Token& other) const
196 return !(*this != other);
199 inline const char* Token::getIdentifier (void) const
201 DE_ASSERT(m_type == IDENTIFIER);
202 return m_arg.identifier;
205 inline float Token::getFloat (void) const
207 DE_ASSERT(m_type == FLOAT_LITERAL);
208 return m_arg.floatValue;
211 inline int Token::getInt (void) const
213 DE_ASSERT(m_type == INT_LITERAL);
214 return m_arg.intValue;
217 inline bool Token::getBool (void) const
219 DE_ASSERT(m_type == BOOL_LITERAL);
220 return m_arg.boolValue;
229 int getSize (void) const { return (int)m_numTokens; }
230 const Token& operator[] (int ndx) const { return m_tokens[ndx]; }
232 TokenStream& operator<< (const Token& token);
240 std::vector<Token> m_tokens;
244 inline TokenStream& TokenStream::operator<< (const Token& token)
246 if (m_tokens.size() == m_numTokens)
247 m_tokens.resize(m_numTokens+ALLOC_SIZE);
249 m_tokens[m_numTokens] = token;
257 #endif // _RSGTOKEN_HPP