TranspilerUtils.js 653 B

1234567891011121314151617181920212223242526272829
  1. export function isExpression( st ) {
  2. return st.isFunctionDeclaration !== true && st.isFor !== true && st.isWhile !== true && st.isConditional !== true && st.isSwitch !== true && st.isStructDefinition !== true;
  3. }
  4. export function isPrimitive( value ) {
  5. return /^(true|false|-?(\d|\.\d))/.test( value );
  6. }
  7. export function isBuiltinType( str ) {
  8. return /^(void|bool|float|u?int|mat[234]|mat[234]x[234]|(u|i|b)?vec[234])$/.test( str );
  9. }
  10. export function toFloatType( type ) {
  11. if ( /^(i?int)$/.test( type ) ) return 'float';
  12. const vecMatch = /^(i|u)?vec([234])$/.exec( type );
  13. if ( vecMatch ) return 'vec' + vecMatch[ 2 ];
  14. return type;
  15. }
粤ICP备19079148号