HLSL: Add namespace grammar and some basic semantics.
Unknown how extensive the semantics need to be yet. Need real
feedback from workloads. This is just done as part of unifying it
with the class/struct namespaces and grammar productions.
diff --git a/Test/baseResults/hlsl.namespace.frag.out b/Test/baseResults/hlsl.namespace.frag.out
new file mode 100755
index 0000000..dae874f
--- /dev/null
+++ b/Test/baseResults/hlsl.namespace.frag.out
@@ -0,0 +1,180 @@
+hlsl.namespace.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:5 Function Definition: N1::getVec( ( temp 4-component vector of float)
+0:5 Function Parameters:
+0:? Sequence
+0:5 Branch: Return with expression
+0:5 'v1' ( global 4-component vector of float)
+0:10 Function Definition: N2::getVec( ( temp 4-component vector of float)
+0:10 Function Parameters:
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'v2' ( global 4-component vector of float)
+0:12 Function Definition: N2::N3::getVec( ( temp 4-component vector of float)
+0:12 Function Parameters:
+0:? Sequence
+0:12 Branch: Return with expression
+0:12 'v2' ( global 4-component vector of float)
+0:15 Function Definition: N2::N3::C1::getVec( ( temp 4-component vector of float)
+0:15 Function Parameters:
+0:15 '@this' ( temp structure{})
+0:? Sequence
+0:15 Branch: Return with expression
+0:15 'v2' ( global 4-component vector of float)
+0:21 Function Definition: @main( ( temp 4-component vector of float)
+0:21 Function Parameters:
+0:? Sequence
+0:22 Branch: Return with expression
+0:22 add ( temp 4-component vector of float)
+0:22 add ( temp 4-component vector of float)
+0:22 add ( temp 4-component vector of float)
+0:22 Function Call: N1::getVec( ( temp 4-component vector of float)
+0:22 Function Call: N2::getVec( ( temp 4-component vector of float)
+0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float)
+0:22 vector-scale ( temp 4-component vector of float)
+0:22 Function Call: N2::N3::C1::getVec( ( temp 4-component vector of float)
+0:22 'N2::gf' ( global float)
+0:21 Function Definition: main( ( temp void)
+0:21 Function Parameters:
+0:? Sequence
+0:21 move second child to first child ( temp 4-component vector of float)
+0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:21 Function Call: @main( ( temp 4-component vector of float)
+0:? Linker Objects
+0:? 'v1' ( global 4-component vector of float)
+0:? 'v2' ( global 4-component vector of float)
+0:? 'N2::gf' ( global float)
+0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:5 Function Definition: N1::getVec( ( temp 4-component vector of float)
+0:5 Function Parameters:
+0:? Sequence
+0:5 Branch: Return with expression
+0:5 'v1' ( global 4-component vector of float)
+0:10 Function Definition: N2::getVec( ( temp 4-component vector of float)
+0:10 Function Parameters:
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'v2' ( global 4-component vector of float)
+0:12 Function Definition: N2::N3::getVec( ( temp 4-component vector of float)
+0:12 Function Parameters:
+0:? Sequence
+0:12 Branch: Return with expression
+0:12 'v2' ( global 4-component vector of float)
+0:15 Function Definition: N2::N3::C1::getVec( ( temp 4-component vector of float)
+0:15 Function Parameters:
+0:15 '@this' ( temp structure{})
+0:? Sequence
+0:15 Branch: Return with expression
+0:15 'v2' ( global 4-component vector of float)
+0:21 Function Definition: @main( ( temp 4-component vector of float)
+0:21 Function Parameters:
+0:? Sequence
+0:22 Branch: Return with expression
+0:22 add ( temp 4-component vector of float)
+0:22 add ( temp 4-component vector of float)
+0:22 add ( temp 4-component vector of float)
+0:22 Function Call: N1::getVec( ( temp 4-component vector of float)
+0:22 Function Call: N2::getVec( ( temp 4-component vector of float)
+0:22 Function Call: N2::N3::getVec( ( temp 4-component vector of float)
+0:22 vector-scale ( temp 4-component vector of float)
+0:22 Function Call: N2::N3::C1::getVec( ( temp 4-component vector of float)
+0:22 'N2::gf' ( global float)
+0:21 Function Definition: main( ( temp void)
+0:21 Function Parameters:
+0:? Sequence
+0:21 move second child to first child ( temp 4-component vector of float)
+0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:21 Function Call: @main( ( temp 4-component vector of float)
+0:? Linker Objects
+0:? 'v1' ( global 4-component vector of float)
+0:? 'v2' ( global 4-component vector of float)
+0:? 'N2::gf' ( global float)
+0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 54
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 52
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 9 "N1::getVec("
+ Name 11 "N2::getVec("
+ Name 13 "N2::N3::getVec("
+ Name 15 "C1"
+ Name 19 "N2::N3::C1::getVec("
+ Name 18 "@this"
+ Name 21 "@main("
+ Name 24 "v1"
+ Name 28 "v2"
+ Name 45 "N2::gf"
+ Name 52 "@entryPointOutput"
+ Decorate 52(@entryPointOutput) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypeFunction 7(fvec4)
+ 15(C1): TypeStruct
+ 16: TypePointer Function 15(C1)
+ 17: TypeFunction 7(fvec4) 16(ptr)
+ 23: TypePointer Private 7(fvec4)
+ 24(v1): 23(ptr) Variable Private
+ 28(v2): 23(ptr) Variable Private
+ 44: TypePointer Private 6(float)
+ 45(N2::gf): 44(ptr) Variable Private
+ 51: TypePointer Output 7(fvec4)
+52(@entryPointOutput): 51(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 53: 7(fvec4) FunctionCall 21(@main()
+ Store 52(@entryPointOutput) 53
+ Return
+ FunctionEnd
+ 9(N1::getVec(): 7(fvec4) Function None 8
+ 10: Label
+ 25: 7(fvec4) Load 24(v1)
+ ReturnValue 25
+ FunctionEnd
+ 11(N2::getVec(): 7(fvec4) Function None 8
+ 12: Label
+ 29: 7(fvec4) Load 28(v2)
+ ReturnValue 29
+ FunctionEnd
+13(N2::N3::getVec(): 7(fvec4) Function None 8
+ 14: Label
+ 32: 7(fvec4) Load 28(v2)
+ ReturnValue 32
+ FunctionEnd
+19(N2::N3::C1::getVec(): 7(fvec4) Function None 17
+ 18(@this): 16(ptr) FunctionParameter
+ 20: Label
+ 35: 7(fvec4) Load 28(v2)
+ ReturnValue 35
+ FunctionEnd
+ 21(@main(): 7(fvec4) Function None 8
+ 22: Label
+ 38: 7(fvec4) FunctionCall 9(N1::getVec()
+ 39: 7(fvec4) FunctionCall 11(N2::getVec()
+ 40: 7(fvec4) FAdd 38 39
+ 41: 7(fvec4) FunctionCall 13(N2::N3::getVec()
+ 42: 7(fvec4) FAdd 40 41
+ 43: 7(fvec4) FunctionCall 19(N2::N3::C1::getVec()
+ 46: 6(float) Load 45(N2::gf)
+ 47: 7(fvec4) VectorTimesScalar 43 46
+ 48: 7(fvec4) FAdd 42 47
+ ReturnValue 48
+ FunctionEnd
diff --git a/Test/hlsl.namespace.frag b/Test/hlsl.namespace.frag
new file mode 100755
index 0000000..76c3062
--- /dev/null
+++ b/Test/hlsl.namespace.frag
@@ -0,0 +1,23 @@
+static float4 v1;
+static float4 v2;
+
+namespace N1 {
+ float4 getVec() { return v1; }
+}
+
+namespace N2 {
+ static float gf;
+ float4 getVec() { return v2; }
+ namespace N3 {
+ float4 getVec() { return v2; }
+
+ class C1 {
+ float4 getVec() { return v2; }
+ };
+ }
+}
+
+float4 main() : SV_Target0
+{
+ return N1::getVec() + N2::getVec() + N2::N3::getVec() + N2::N3::C1::getVec() * N2::gf;
+}