Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
58ab0020
Commit
58ab0020
authored
Nov 25, 2010
by
Roberto Raggi
Browse files
Initial work on the GLSL symbols.
parent
2960c735
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/libs/glsl/glsl-lib.pri
View file @
58ab0020
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/glslsymbol.h
$$PWD/glslsemantic.h $$PWD/glsltype.h $$PWD/glsltypes.h $$PWD/glslsymbol.h
$$PWD/glslsymbols.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/glslsymbol.cpp
$$PWD/glslsemantic.cpp $$PWD/glsltype.cpp $$PWD/glsltypes.cpp $$PWD/glslsymbol.cpp
$$PWD/glslsymbols.cpp
OTHER_FILES = $$PWD/glsl.g
src/libs/glsl/glsl.h
View file @
58ab0020
...
...
@@ -61,6 +61,13 @@ class OpaqueType;
class
VectorType
;
class
MatrixType
;
// symbols
class
Struct
;
class
Function
;
class
Argument
;
class
Block
;
class
Variable
;
class
AST
;
template
<
typename
T
>
class
List
;
}
...
...
src/libs/glsl/glslsymbol.cpp
View file @
58ab0020
...
...
@@ -31,31 +31,36 @@
using
namespace
GLSL
;
Symbol
::
Symbol
(
Scope
*
scope
)
:
_scope
(
scope
)
{
}
Symbol
::~
Symbol
()
{
}
Scope
::
Scope
(
Scope
*
enclosingScope
)
:
_enclosingScope
(
enclosingScope
)
Scope
*
Symbol
::
scope
()
const
{
return
_scope
;
}
Scope
*
Scope
::
enclosingScope
()
const
void
Symbol
::
setScope
(
Scope
*
scope
)
{
return
_enclosingS
cope
;
_scope
=
s
cope
;
}
void
Scope
::
setEnclosingScope
(
Scope
*
enclosingScope
)
Scope
::
Scope
(
Scope
*
enclosingScope
)
:
Symbol
(
enclosingScope
)
{
_enclosingScope
=
enclosingScope
;
}
Symbol
*
Scope
::
lookup
(
const
QString
&
name
)
const
{
if
(
Symbol
*
s
=
find
(
name
))
return
s
;
else
if
(
Scope
*
e
=
enclosingS
cope
())
return
e
->
lookup
(
name
);
else
if
(
Scope
*
s
=
s
cope
())
return
s
->
lookup
(
name
);
else
return
0
;
}
src/libs/glsl/glslsymbol.h
View file @
58ab0020
...
...
@@ -37,31 +37,37 @@ namespace GLSL {
class
Symbol
;
class
Scope
;
class
Symbol
class
GLSL_EXPORT
Symbol
{
public:
Symbol
(
Scope
*
scope
=
0
);
virtual
~
Symbol
();
Scope
*
scope
()
const
;
void
setScope
(
Scope
*
scope
);
virtual
Scope
*
asScope
()
{
return
0
;
}
virtual
Struct
*
asStruct
()
{
return
0
;
}
virtual
Function
*
asFunction
()
{
return
0
;
}
virtual
Argument
*
asArgument
()
{
return
0
;
}
virtual
Block
*
asBlock
()
{
return
0
;
}
virtual
Variable
*
asVariable
()
{
return
0
;
}
virtual
const
Type
*
type
()
const
=
0
;
virtual
Type
*
type
()
const
=
0
;
private:
Scope
*
_scope
;
};
class
Scope
:
public
Symbol
class
GLSL_EXPORT
Scope
:
public
Symbol
{
public:
Scope
(
Scope
*
enclosingScope
=
0
);
Scope
*
enclosingScope
()
const
;
void
setEnclosingScope
(
Scope
*
enclosingScope
);
Scope
(
Scope
*
sscope
=
0
);
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
...
...
src/libs/glsl/glslsymbols.cpp
0 → 100644
View file @
58ab0020
/**************************************************************************
**
** 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 "glsltypes.h"
#include "glslsymbols.h"
#include <QtCore/qglobal.h>
using
namespace
GLSL
;
Argument
::
Argument
(
Function
*
scope
)
:
Symbol
(
scope
)
,
_type
(
0
)
{
}
QString
Argument
::
name
()
const
{
return
_name
;
}
void
Argument
::
setName
(
const
QString
&
name
)
{
_name
=
name
;
}
const
Type
*
Argument
::
type
()
const
{
return
_type
;
}
void
Argument
::
setType
(
const
Type
*
type
)
{
_type
=
type
;
}
Block
::
Block
(
Scope
*
enclosingScope
)
:
Scope
(
enclosingScope
)
{
}
void
Block
::
addMember
(
const
QString
&
name
,
Symbol
*
symbol
)
{
_members
.
insert
(
name
,
symbol
);
}
const
Type
*
Block
::
type
()
const
{
// ### assert?
return
0
;
}
Symbol
*
Block
::
find
(
const
QString
&
name
)
const
{
return
_members
.
value
(
name
);
}
Variable
::
Variable
(
Scope
*
scope
)
:
Symbol
(
scope
)
,
_type
(
0
)
{
}
QString
Variable
::
name
()
const
{
return
_name
;
}
void
Variable
::
setName
(
const
QString
&
name
)
{
_name
=
name
;
}
const
Type
*
Variable
::
type
()
const
{
return
_type
;
}
void
Variable
::
setType
(
const
Type
*
type
)
{
_type
=
type
;
}
src/libs/glsl/glslsymbols.h
0 → 100644
View file @
58ab0020
/**************************************************************************
**
** 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 GLSLSYMBOLS_H
#define GLSLSYMBOLS_H
#include "glsltype.h"
#include "glslsymbol.h"
#include <QtCore/QVector>
#include <QtCore/QString>
#include <QtCore/QHash>
namespace
GLSL
{
class
GLSL_EXPORT
Argument
:
public
Symbol
{
public:
Argument
(
Function
*
scope
);
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
virtual
const
Type
*
type
()
const
;
void
setType
(
const
Type
*
type
);
virtual
Argument
*
asArgument
()
{
return
this
;
}
private:
QString
_name
;
const
Type
*
_type
;
};
class
GLSL_EXPORT
Variable
:
public
Symbol
{
public:
Variable
(
Scope
*
scope
);
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
virtual
const
Type
*
type
()
const
;
void
setType
(
const
Type
*
type
);
virtual
Variable
*
asVariable
()
{
return
this
;
}
private:
QString
_name
;
const
Type
*
_type
;
};
class
GLSL_EXPORT
Block
:
public
Scope
{
public:
Block
(
Scope
*
enclosingScope
=
0
);
void
addMember
(
const
QString
&
name
,
Symbol
*
symbol
);
virtual
Block
*
asBlock
()
{
return
this
;
}
virtual
const
Type
*
type
()
const
;
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
private:
QHash
<
QString
,
Symbol
*>
_members
;
};
}
// end of namespace GLSL
#endif // GLSLSYMBOLS_H
src/libs/glsl/glsltype.h
View file @
58ab0020
...
...
@@ -49,6 +49,9 @@ public:
virtual
const
VectorType
*
asVectorType
()
const
{
return
0
;
}
virtual
const
MatrixType
*
asMatrixType
()
const
{
return
0
;
}
virtual
const
Struct
*
asStructType
()
const
{
return
0
;
}
virtual
const
Function
*
asFunctionType
()
const
{
return
0
;
}
virtual
bool
isEqualTo
(
const
Type
*
other
)
const
=
0
;
virtual
bool
isLessThan
(
const
Type
*
other
)
const
=
0
;
};
...
...
src/libs/glsl/glsltypes.cpp
View file @
58ab0020
...
...
@@ -28,7 +28,7 @@
**************************************************************************/
#include "glsltypes.h"
#include
<QtCore/qglobal
.h
>
#include
"glslsymbols
.h
"
using
namespace
GLSL
;
...
...
@@ -195,3 +195,76 @@ bool MatrixType::isLessThan(const Type *other) const
return
false
;
}
bool
Struct
::
isEqualTo
(
const
Type
*
other
)
const
{
Q_UNUSED
(
other
);
return
false
;
}
bool
Struct
::
isLessThan
(
const
Type
*
other
)
const
{
Q_UNUSED
(
other
);
return
false
;
}
QString
Function
::
name
()
const
{
return
_name
;
}
void
Function
::
setName
(
const
QString
&
name
)
{
_name
=
name
;
}
const
Type
*
Function
::
returnType
()
const
{
return
_returnType
;
}
void
Function
::
setReturnType
(
const
Type
*
returnType
)
{
_returnType
=
returnType
;
}
QVector
<
Argument
*>
Function
::
arguments
()
const
{
return
_arguments
;
}
void
Function
::
addArgument
(
Argument
*
arg
)
{
_arguments
.
append
(
arg
);
}
int
Function
::
argumentCount
()
const
{
return
_arguments
.
size
();
}
Argument
*
Function
::
argumentAt
(
int
index
)
const
{
return
_arguments
.
at
(
index
);
}
bool
Function
::
isEqualTo
(
const
Type
*
other
)
const
{
Q_UNUSED
(
other
);
return
false
;
}
bool
Function
::
isLessThan
(
const
Type
*
other
)
const
{
Q_UNUSED
(
other
);
return
false
;
}
Symbol
*
Function
::
find
(
const
QString
&
name
)
const
{
foreach
(
Argument
*
arg
,
_arguments
)
{
if
(
arg
->
name
()
==
name
)
return
arg
;
}
return
0
;
}
src/libs/glsl/glsltypes.h
View file @
58ab0020
...
...
@@ -30,6 +30,9 @@
#define GLSLTYPES_H
#include "glsltype.h"
#include "glslsymbol.h"
#include <QtCore/QVector>
#include <QtCore/QString>
namespace
GLSL
{
...
...
@@ -133,6 +136,53 @@ private:
int
_rows
;
};
class
GLSL_EXPORT
Struct
:
public
Type
,
public
Symbol
{
public:
Struct
(
Scope
*
scope
=
0
);
// as Type
virtual
const
Struct
*
asStructType
()
const
{
return
this
;
}
virtual
bool
isEqualTo
(
const
Type
*
other
)
const
;
virtual
bool
isLessThan
(
const
Type
*
other
)
const
;
// as Symbol
virtual
Struct
*
asStruct
()
{
return
this
;
}
// as Symbol
};
class
GLSL_EXPORT
Function
:
public
Type
,
public
Scope
{
public:
Function
(
Scope
*
scope
=
0
);
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
const
Type
*
returnType
()
const
;
void
setReturnType
(
const
Type
*
returnType
);
QVector
<
Argument
*>
arguments
()
const
;
void
addArgument
(
Argument
*
arg
);
int
argumentCount
()
const
;
Argument
*
argumentAt
(
int
index
)
const
;
// as Type
virtual
const
Function
*
asFunctionType
()
const
{
return
this
;
}
virtual
bool
isEqualTo
(
const
Type
*
other
)
const
;
virtual
bool
isLessThan
(
const
Type
*
other
)
const
;
// as Symbol
virtual
Function
*
asFunction
()
{
return
this
;
}
virtual
const
Type
*
type
()
const
{
return
this
;
}
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
private:
QString
_name
;
const
Type
*
_returnType
;
QVector
<
Argument
*>
_arguments
;
};
}
// end of namespace GLSL
#endif // GLSLTYPES_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment