smali.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Language: Smali
  3. Author: Dennis Titze <dennis.titze@gmail.com>
  4. Description: Basic Smali highlighting
  5. Website: https://github.com/JesusFreke/smali
  6. */
  7. function smali(hljs) {
  8. var smali_instr_low_prio = ['add', 'and', 'cmp', 'cmpg', 'cmpl', 'const', 'div', 'double', 'float', 'goto', 'if', 'int', 'long', 'move', 'mul', 'neg', 'new', 'nop', 'not', 'or', 'rem', 'return', 'shl', 'shr', 'sput', 'sub', 'throw', 'ushr', 'xor'];
  9. var smali_instr_high_prio = ['aget', 'aput', 'array', 'check', 'execute', 'fill', 'filled', 'goto/16', 'goto/32', 'iget', 'instance', 'invoke', 'iput', 'monitor', 'packed', 'sget', 'sparse'];
  10. var smali_keywords = ['transient', 'constructor', 'abstract', 'final', 'synthetic', 'public', 'private', 'protected', 'static', 'bridge', 'system'];
  11. return {
  12. name: 'Smali',
  13. aliases: ['smali'],
  14. contains: [
  15. {
  16. className: 'string',
  17. begin: '"', end: '"',
  18. relevance: 0
  19. },
  20. hljs.COMMENT(
  21. '#',
  22. '$',
  23. {
  24. relevance: 0
  25. }
  26. ),
  27. {
  28. className: 'keyword',
  29. variants: [
  30. {begin: '\\s*\\.end\\s[a-zA-Z0-9]*'},
  31. {begin: '^[ ]*\\.[a-zA-Z]*', relevance: 0},
  32. {begin: '\\s:[a-zA-Z_0-9]*', relevance: 0},
  33. {begin: '\\s(' + smali_keywords.join('|') + ')'}
  34. ]
  35. },
  36. {
  37. className: 'built_in',
  38. variants : [
  39. {
  40. begin: '\\s('+smali_instr_low_prio.join('|')+')\\s'
  41. },
  42. {
  43. begin: '\\s('+smali_instr_low_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)+\\s',
  44. relevance: 10
  45. },
  46. {
  47. begin: '\\s('+smali_instr_high_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)*\\s',
  48. relevance: 10
  49. },
  50. ]
  51. },
  52. {
  53. className: 'class',
  54. begin: 'L[^\(;:\n]*;',
  55. relevance: 0
  56. },
  57. {
  58. begin: '[vp][0-9]+',
  59. }
  60. ]
  61. };
  62. }
  63. module.exports = smali;