append(format("Literal: %s -> %s", literal.token, format_type(literal.type)));
}
-void DumpTree::visit(ParenthesizedExpression &parexpr)
-{
- annotated_branch(format("(expr) -> %s", format_type(parexpr.type)), *parexpr.expression);
-}
-
void DumpTree::visit(VariableReference &var)
{
string text;
virtual void visit(Block &);
virtual void visit(Literal &);
- virtual void visit(ParenthesizedExpression &);
virtual void visit(VariableReference &);
virtual void visit(InterfaceBlockReference &);
virtual void visit(MemberAccess &);
r_result_valid = true;
}
-void ExpressionEvaluator::visit(ParenthesizedExpression &parexp)
-{
- parexp.expression->visit(*this);
-}
-
void ExpressionEvaluator::visit(VariableReference &var)
{
if(!var.declaration)
using NodeVisitor::visit;
virtual void visit(Literal &);
- virtual void visit(ParenthesizedExpression &);
virtual void visit(VariableReference &);
virtual void visit(UnaryExpression &);
virtual void visit(BinaryExpression &);
resolve(literal, find_type(BasicTypeDeclaration::FLOAT, 32), false);
}
-void ExpressionResolver::visit(ParenthesizedExpression &parexpr)
-{
- TraversingVisitor::visit(parexpr);
- resolve(parexpr, parexpr.expression->type, parexpr.expression->lvalue);
-}
-
void ExpressionResolver::visit(VariableReference &var)
{
if(var.declaration)
void resolve(Expression &, TypeDeclaration *, bool);
virtual void visit(Literal &);
- virtual void visit(ParenthesizedExpression &);
virtual void visit(VariableReference &);
virtual void visit(InterfaceBlockReference &);
virtual void visit(MemberAccess &);
append(literal.token);
}
-void Formatter::visit(ParenthesizedExpression &parexpr)
-{
- append('(');
- parexpr.expression->visit(*this);
- append(')');
-}
-
void Formatter::visit(VariableReference &var)
{
append(var.name);
virtual void visit(Block &);
void visit_expression(Expression &, const Operator *, bool);
virtual void visit(Literal &);
- virtual void visit(ParenthesizedExpression &);
virtual void visit(VariableReference &);
virtual void visit(InterfaceBlockReference &);
virtual void visit(MemberAccess &);
if(token=="(")
{
tokenizer.parse_token();
- RefPtr<ParenthesizedExpression> parexpr = create_node<ParenthesizedExpression>();
- parexpr->expression = parse_expression();
+ left = parse_expression();
tokenizer.expect(")");
- left = parexpr;
}
else if(isdigit(token[0]) || token=="true" || token=="false")
left = parse_literal();
}
-void ParenthesizedExpression::visit(NodeVisitor &visitor)
-{
- visitor.visit(*this);
-}
-
-
VariableReference::VariableReference():
declaration(0)
{ }
virtual void visit(NodeVisitor &);
};
-struct ParenthesizedExpression: Expression
-{
- NodePtr<Expression> expression;
-
- virtual ParenthesizedExpression *clone() const { return new ParenthesizedExpression(*this); }
- virtual void visit(NodeVisitor &);
-};
-
struct VariableReference: Expression
{
std::string name;
expr->visit(*this);
}
-void TraversingVisitor::visit(ParenthesizedExpression &parexpr)
-{
- visit(parexpr.expression);
-}
-
void TraversingVisitor::visit(MemberAccess &memacc)
{
visit(memacc.left);
virtual void visit(Block &) { }
virtual void visit(Literal &) { }
- virtual void visit(ParenthesizedExpression &) { }
virtual void visit(VariableReference &) { }
virtual void visit(InterfaceBlockReference &) { }
virtual void visit(MemberAccess &) { }
virtual void enter(Block &) { }
virtual void visit(Block &);
virtual void visit(RefPtr<Expression> &);
- virtual void visit(ParenthesizedExpression &);
virtual void visit(MemberAccess &);
virtual void visit(Swizzle &);
virtual void visit(UnaryExpression &);
b = b&&float(i)==f;
int j = 1;
i = i|1;
- j = j<<(i%5);
+ j = j<<i%5;
b = b||i!=j;
ivec2 iv;
i = i<<j;
--- /dev/null
+struct LightParams
+{
+ uniform vec3 ambient;
+ uniform vec3 color;
+ uniform float intensity;
+ uniform vec3 dir;
+};
+uniform LightParams light;
+uniform vec3 material_color;
+uniform mat4 mvp;
+uniform vec3 offset;
+uniform sampler2D occlusion_map;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+void main()
+{
+ vec4 p = position+vec4(offset, 1.0);
+ gl_Position = mvp*p;
+ passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+ float occlusion = float(texture(occlusion_map, texcoord));
+ vec3 light_color = light.color*light.intensity;
+ vec3 l = light.ambient+light_color*max(dot(light.dir, normalize(normal)), 0.0);
+ frag_color = vec4(material_color*l*occlusion, 1.0);
+}
+
+/* Expected output: vertex
+uniform mat4 mvp;
+uniform vec3 offset;
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+out vec3 _vs_out_normal;
+out vec2 _vs_out_texcoord;
+void main()
+{
+ gl_Position = mvp*(position+vec4(offset, 1.0));
+ _vs_out_normal = normal;
+ _vs_out_texcoord = texcoord;
+}
+*/
+
+/* Expected output: fragment
+struct LightParams
+{
+ uniform vec3 ambient;
+ uniform vec3 color;
+ uniform float intensity;
+ uniform vec3 dir;
+};
+uniform LightParams light;
+uniform vec3 material_color;
+uniform sampler2D occlusion_map;
+layout(location=0) out vec4 frag_color;
+in vec2 _vs_out_texcoord;
+in vec3 _vs_out_normal;
+void main()
+{
+ frag_color = vec4(material_color*(light.ambient+light.color*light.intensity*max(dot(light.dir, normalize(_vs_out_normal)), 0.0))*float(texture(occlusion_map, _vs_out_texcoord)), 1.0);
+}
+*/