return a;
}
-Variable *Engine::newVariable(Scope *scope, const QString &name, const Type *type)
+Variable *Engine::newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers)
{
Variable *var = new Variable(scope);
var->setName(name);
var->setType(type);
+ var->setQualifiers(qualifiers);
_symbols.append(var);
return var;
}
Block *newBlock(Scope *scope = 0);
Function *newFunction(Scope *scope = 0);
Argument *newArgument(Function *function, const QString &name, const Type *type);
- Variable *newVariable(Scope *scope, const QString &name, const Type *type);
+ Variable *newVariable(Scope *scope, const QString &name, const Type *type, int qualifiers = 0);
MemoryPool *pool();
const Type *ty = type(ast->type);
ExprResult initializer = expression(ast->initializer);
if (ast->name) {
- Variable *var = _engine->newVariable(_scope, *ast->name, ty);
+ QualifiedTypeAST *qtype = ast->type->asQualifiedType();
+ int qualifiers = 0;
+ if (qtype)
+ qualifiers = qtype->qualifiers;
+ Variable *var = _engine->newVariable(_scope, *ast->name, ty, qualifiers);
_scope->add(var);
}
return false;
virtual const Type *type() const;
void setType(const Type *type);
+ int qualifiers() const { return _qualifiers; }
+ void setQualifiers(int qualifiers) { _qualifiers = qualifiers; }
+
virtual Variable *asVariable() { return this; }
private:
const Type *_type;
+ int _qualifiers;
};
class GLSL_EXPORT Block: public Scope
m_varIcon(":/glsleditor/images/var.png"),
m_functionIcon(":/glsleditor/images/func.png"),
m_typeIcon(":/glsleditor/images/type.png"),
+ m_constIcon(":/glsleditor/images/const.png"),
+ m_attributeIcon(":/glsleditor/images/attribute.png"),
+ m_uniformIcon(":/glsleditor/images/uniform.png"),
+ m_varyingIcon(":/glsleditor/images/varying.png"),
m_otherIcon(":/glsleditor/images/other.png")
{
const QIcon keywordIcon(QLatin1String(":/glsleditor/images/keyword.png"));
foreach (GLSL::Symbol *s, members) {
TextEditor::CompletionItem item(this);
- if (s->asVariable() || s->asArgument())
+ GLSL::Variable *var = s->asVariable();
+ if (var) {
+ int storageType = var->qualifiers() & GLSL::QualifiedTypeAST::StorageMask;
+ if (storageType == GLSL::QualifiedTypeAST::Attribute)
+ item.icon = m_attributeIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Uniform)
+ item.icon = m_uniformIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Varying)
+ item.icon = m_varyingIcon;
+ else if (storageType == GLSL::QualifiedTypeAST::Const)
+ item.icon = m_constIcon;
+ else
+ item.icon = m_varIcon;
+ } else if (s->asArgument()) {
item.icon = m_varIcon;
- else if (s->asFunction() || s->asOverloadSet())
+ } else if (s->asFunction() || s->asOverloadSet()) {
item.icon = m_functionIcon;
- else if (s->asStruct())
+ } else if (s->asStruct()) {
item.icon = m_typeIcon;
- else
+ } else {
item.icon = m_otherIcon;
+ }
item.text = s->name();
if (specialMembers.contains(item.text))
item.order = SpecialMemberOrder;
<file>images/var.png</file>
<file>images/func.png</file>
<file>images/type.png</file>
+ <file>images/const.png</file>
+ <file>images/attribute.png</file>
+ <file>images/uniform.png</file>
+ <file>images/varying.png</file>
<file>images/other.png</file>
</qresource>
</RCC>