| 
						
						
						
					 | 
					 | 
					@ -1,8 +1,8 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					use crate::parser::{tokenize, parse};
 | 
					 | 
					 | 
					 | 
					use crate::parser::{tokenize, parse};
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					use crate::compiler::meta_compile;
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#[test]
 | 
					 | 
					 | 
					 | 
					#[test]
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					fn test_compile() {
 | 
					 | 
					 | 
					 | 
					fn test_compile() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    use crate::compiler::*;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    let src = "
 | 
					 | 
					 | 
					 | 
					    let src = "
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					(module Shader Logical GLSL450)
 | 
					 | 
					 | 
					 | 
					(module Shader Logical GLSL450)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					(import :std GLSL.std.450)
 | 
					 | 
					 | 
					 | 
					(import :std GLSL.std.450)
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -19,7 +19,65 @@ fn test_compile() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            1.0)))
 | 
					 | 
					 | 
					 | 
					            1.0)))
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					";
 | 
					 | 
					 | 
					 | 
					";
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    let mut ast = parse(tokenize(src));
 | 
					 | 
					 | 
					 | 
					    let mut ast = parse(tokenize(src));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    println!("{:?}", ast);
 | 
					 | 
					 | 
					 | 
					    println!("{:#?}", ast);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    let module = meta_compile(&mut ast);
 | 
					 | 
					 | 
					 | 
					    let module = meta_compile(&mut ast);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    println!("{:?}", module);
 | 
					 | 
					 | 
					 | 
					    println!("{:#?}", module);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    //let test_module: Module = Module { capabilities: [Shader], entry_points: [EntryPoint { execution_model: Fragment, execution_mode: OriginUpperLeft, name: "main", interface: [":frag-coord", ":out-color"] }], globals: [GlobalVariable { name: "frag-coord", typ: "*v4f32i", storage_class: Input, decorations: [Builtin(FragCoord)] }, GlobalVariable { name: "out-color", typ: "*v4f32o", storage_class: Output, decorations: [Location(0)] }], functions: [Function { name: "main", return_type: "void", arguments: [], body: Some([]), ast: Some(List([List([Symbol("store-ptr"), List([Symbol("out-color")]), List([Symbol("v4f32i"), List([Symbol("/"), List([Symbol(".xy"), List([Symbol("load-ptr"), Symbol("frag-coord")])]), List([Symbol("v2f32"), Symbol("1920.0"), Symbol("1080.0")])]), Symbol("1.0"), Symbol("1.0")])])])) }], memory_model: Memory { addressing_model: Logical, memory_model: GLSL450 }, imports: [Import { name: ":std", value: "GLSL.std.450" }] };
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    let test_module = Module {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        capabilities: vec![Capability::Shader],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        entry_points: vec![EntryPoint {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            execution_model: ExecutionModel::Fragment,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            execution_mode: ExecutionMode::OriginUpperLeft,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            name: "main".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            interface: vec![":frag-coord".to_string(), ":out-color".to_string()],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        globals: vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            GlobalVariable {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                name: "frag-coord".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                typ: "*v4f32i".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                storage_class: StorageClass::Input,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                decorations: vec![Decoration::Builtin(BuiltinDecoration::FragCoord)],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            },
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            GlobalVariable {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                name: "out-color".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                typ: "*v4f32o".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                storage_class: StorageClass::Output,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                decorations: vec![Decoration::Location(0)],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            },
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        ],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        functions: vec![Function {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            name: "main".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            return_type: "void".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            arguments: vec![],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            body: Some(vec![]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            ast: Some(Ast::List(vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                Ast::List(vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    Ast::Symbol("store-ptr".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    Ast::List(vec![Ast::Symbol("out-color".to_string())]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    Ast::List(vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        Ast::Symbol("v4f32i".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        Ast::List(vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            Ast::Symbol("/".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            Ast::List(vec![
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                Ast::Symbol(".xy".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                Ast::List(vec![Ast::Symbol("load-ptr".to_string()), Ast::Symbol("frag-coord".to_string())]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            ]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            Ast::List(vec![Ast::Symbol("v2f32".to_string()), Ast::Symbol("1920.0".to_string()), Ast::Symbol("1080.0".to_string())]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        ]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        Ast::Symbol("1.0".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        Ast::Symbol("1.0".to_string()),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    ]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                ]),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            ])),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        memory_model: Memory {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            addressing_model: AddressingModel::Logical,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            memory_model: MemoryModel::GLSL450,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        },
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        imports: vec![Import {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            name: ":std".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            value: "GLSL.std.450".to_string(),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }],
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    };
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    assert_eq!(module, test_module);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 |