@ -14,11 +14,13 @@ pub enum Type {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     Float ( u32 ) , 
 
					 
					 
					 
					     Float ( u32 ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     Int ( u32 ) , 
 
					 
					 
					 
					     Int ( u32 ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     Unsigned ( u32 ) , 
 
					 
					 
					 
					     Unsigned ( u32 ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					     Void , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					} 
 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					impl   fmt ::Display   for   Type   { 
 
					 
					 
					 
					impl   fmt ::Display   for   Type   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     fn  fmt ( & self ,   f : & mut   fmt ::Formatter )   -> fmt ::Result   { 
 
					 
					 
					 
					     fn  fmt ( & self ,   f : & mut   fmt ::Formatter )   -> fmt ::Result   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					         match   self   { 
 
					 
					 
					 
					         match   self   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             Type ::Void   = >   write! ( f ,   "<>" ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					             Type ::Pointer ( typ ,   storage_class )   = >   match   storage_class   { 
 
					 
					 
					 
					             Type ::Pointer ( typ ,   storage_class )   = >   match   storage_class   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                 StorageClass ::Input   = >   write! ( f ,   "*{}i" ,   typ ) , 
 
					 
					 
					 
					                 StorageClass ::Input   = >   write! ( f ,   "*{}i" ,   typ ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                 StorageClass ::Output   = >   write! ( f ,   "*{}o" ,   typ ) , 
 
					 
					 
					 
					                 StorageClass ::Output   = >   write! ( f ,   "*{}o" ,   typ ) , 
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -42,6 +44,10 @@ pub fn parse_type(typ: &String) -> Type {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     let   c   =   typ . chars ( ) . next ( ) . unwrap ( ) ; 
 
					 
					 
					 
					     let   c   =   typ . chars ( ) . next ( ) . unwrap ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     match   c   { 
 
					 
					 
					 
					     match   c   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         '<'   = >   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             assert_eq! ( typ . as_str ( ) ,   "<>" ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             Type ::Void 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					         '*'   = >   { 
 
					 
					 
					 
					         '*'   = >   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					             let   mut   chars   =   typ . chars ( ) ; 
 
					 
					 
					 
					             let   mut   chars   =   typ . chars ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					             chars . next ( ) ; 
 
					 
					 
					 
					             chars . next ( ) ; 
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -79,6 +85,9 @@ pub fn parse_type(typ: &String) -> Type {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					fn  emit_type ( typ : Type ,   ops : & mut   Vec < ( String ,   String ) > )   { 
 
					 
					 
					 
					fn  emit_type ( typ : Type ,   ops : & mut   Vec < ( String ,   String ) > )   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     match   & typ   { 
 
					 
					 
					 
					     match   & typ   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         Type ::Void   = >   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             ops . push ( ( "%void" . to_string ( ) ,   "OpTypeVoid" . to_string ( ) ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					         Type ::Unsigned ( size )   = >   { 
 
					 
					 
					 
					         Type ::Unsigned ( size )   = >   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					             ops . push ( ( 
 
					 
					 
					 
					             ops . push ( ( 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					                 format! ( "%u{}" ,   size ) . to_string ( ) , 
 
					 
					 
					 
					                 format! ( "%u{}" ,   size ) . to_string ( ) , 
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -129,7 +138,13 @@ fn emit_type(typ: Type, ops: &mut Vec<(String, String)>) {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					} 
 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					fn  fix_name ( name : & String )   -> String  { 
 
					 
					 
					 
					fn  fix_name ( name : & String )   -> String  { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     format! ( "%{}" ,   name . clone ( ) . replace ( "-" ,   "_" ) . replace ( "*" ,   "p" ) ) 
 
					 
					 
					 
					     format! ( 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         "%{}" , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         name . clone ( ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             . replace ( "-" ,   "_" ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             . replace ( "*" ,   "p" ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             . replace ( "<>" ,   "void" ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					     ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					} 
 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					fn  has_id ( name : String ,   ops : & Vec < ( Option < String > ,   Vec < String > ) > )   -> bool  { 
 
					 
					 
					 
					fn  has_id ( name : String ,   ops : & Vec < ( Option < String > ,   Vec < String > ) > )   -> bool  { 
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -248,6 +263,24 @@ pub fn spirv_meta(module: Module) -> String {
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					         } 
 
					 
					 
					 
					         } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     } 
 
					 
					 
					 
					     } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					     for   fun   in   module . functions   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         let   name   =   fix_name ( & fun . name ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         let   return_type   =   fix_name ( & fun . return_type ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         let   mut   type_ops   =   Vec ::new ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         emit_type ( parse_type ( & fun . return_type ) ,   & mut   type_ops ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         for   op   in   type_ops   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             if   has_id ( op . 0. clone ( ) ,   & ops )   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					                 continue ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             ops . push ( ( Some ( op . 0 ) ,   vec! [ op . 1 ] ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         // Push OpFunctionType
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         ops . push ( ( 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             Some ( name . clone ( ) ) , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					             vec! [ "OpTypeFunction" . to_string ( ) ,   return_type . clone ( ) ] , 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					         ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					     } 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					     for   op   in   ops   { 
 
					 
					 
					 
					     for   op   in   ops   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					         if   op . 0. is_some ( )   { 
 
					 
					 
					 
					         if   op . 0. is_some ( )   { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					             write! ( spirv_asm ,   "{} = " ,   op . 0. unwrap ( ) ) . unwrap ( ) ; 
 
					 
					 
					 
					             write! ( spirv_asm ,   "{} = " ,   op . 0. unwrap ( ) ) . unwrap ( ) ;