1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Random Shader Generator
3 * ----------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 *//*--------------------------------------------------------------------*/
24 #include "rsgToken.hpp"
31 Token::Token (const char* identifier)
34 m_arg.identifier = deStrdup(identifier);
35 if (!m_arg.identifier)
36 throw std::bad_alloc();
41 if (m_type == IDENTIFIER)
42 deFree(m_arg.identifier);
45 Token& Token::operator= (const Token& other)
47 if (m_type == IDENTIFIER)
49 deFree(m_arg.identifier);
50 m_arg.identifier = DE_NULL;
53 m_type = other.m_type;
55 if (m_type == IDENTIFIER)
57 m_arg.identifier = deStrdup(other.m_arg.identifier);
58 if (!m_arg.identifier)
59 throw std::bad_alloc();
61 else if (m_type == FLOAT_LITERAL)
62 m_arg.floatValue = other.m_arg.floatValue;
63 else if (m_type == INT_LITERAL)
64 m_arg.intValue = other.m_arg.intValue;
65 else if (m_type == BOOL_LITERAL)
66 m_arg.boolValue = other.m_arg.boolValue;
71 Token::Token (const Token& other)
77 bool Token::operator!= (const Token& other) const
79 if (m_type != other.m_type)
82 if (m_type == IDENTIFIER && !deStringEqual(m_arg.identifier, other.m_arg.identifier))
84 else if (m_type == FLOAT_LITERAL && m_arg.floatValue != other.m_arg.floatValue)
86 else if (m_type == INT_LITERAL && m_arg.intValue != other.m_arg.intValue)
88 else if (m_type == BOOL_LITERAL && m_arg.boolValue != other.m_arg.boolValue)
94 TokenStream::TokenStream (void)
95 : m_tokens (ALLOC_SIZE)
100 TokenStream::~TokenStream (void)