Commit 68ddcab8 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Introduced GLSL::Symbol.

parent 8b226452
HEADERS += $$PWD/glsl.h $$PWD/glsllexer.h $$PWD/glslparser.h $$PWD/glslparsertable_p.h $$PWD/glslast.h \
$$PWD/glslastvisitor.h $$PWD/glslengine.h $$PWD/glslmemorypool.h $$PWD/glslastdump.h \
$$PWD/glslsemantic.h $$PWD/glsltype.h $$PWD/glsltypes.h
$$PWD/glslsemantic.h $$PWD/glsltype.h $$PWD/glsltypes.h $$PWD/glslsymbol.h
SOURCES += $$PWD/glslkeywords.cpp $$PWD/glslparser.cpp $$PWD/glslparsertable.cpp \
$$PWD/glsllexer.cpp $$PWD/glslast.cpp \
$$PWD/glslastvisitor.cpp $$PWD/glslengine.cpp $$PWD/glslmemorypool.cpp $$PWD/glslastdump.cpp \
$$PWD/glslsemantic.cpp $$PWD/glsltype.cpp $$PWD/glsltypes.cpp
$$PWD/glslsemantic.cpp $$PWD/glsltype.cpp $$PWD/glsltypes.cpp $$PWD/glslsymbol.cpp
OTHER_FILES = $$PWD/glsl.g
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "glslsymbol.h"
using namespace GLSL;
Symbol::~Symbol()
{
}
Scope::Scope(Scope *enclosingScope)
: _enclosingScope(enclosingScope)
{
}
Scope *Scope::enclosingScope() const
{
return _enclosingScope;
}
void Scope::setEnclosingScope(Scope *enclosingScope)
{
_enclosingScope = enclosingScope;
}
Symbol *Scope::lookup(const QString &name) const
{
if (Symbol *s = find(name))
return s;
else if (Scope *e = enclosingScope())
return e->lookup(name);
else
return 0;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef GLSLSYMBOL_H
#define GLSLSYMBOL_H
#include "glsl.h"
namespace GLSL {
class Symbol;
class Scope;
class Symbol
{
public:
virtual ~Symbol();
virtual Scope *asScope() { return 0; }
virtual Type *type() const = 0;
};
class Scope: public Symbol
{
public:
Scope(Scope *enclosingScope = 0);
Scope *enclosingScope() const;
void setEnclosingScope(Scope *enclosingScope);
Symbol *lookup(const QString &name) const;
virtual Symbol *find(const QString &name) const = 0;
virtual Scope *asScope() { return this; }
private:
Scope *_enclosingScope;
};
} // end of namespace GLSL
#endif // GLSLSYMBOL_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment