smali.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. module.exports = function(hljs) {
  2. 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'];
  3. var smali_instr_high_prio = ['aget', 'aput', 'array', 'check', 'execute', 'fill', 'filled', 'goto/16', 'goto/32', 'iget', 'instance', 'invoke', 'iput', 'monitor', 'packed', 'sget', 'sparse'];
  4. var smali_keywords = ['transient', 'constructor', 'abstract', 'final', 'synthetic', 'public', 'private', 'protected', 'static', 'bridge', 'system'];
  5. return {
  6. aliases: ['smali'],
  7. contains: [
  8. {
  9. className: 'string',
  10. begin: '"', end: '"',
  11. relevance: 0
  12. },
  13. hljs.COMMENT(
  14. '#',
  15. '$',
  16. {
  17. relevance: 0
  18. }
  19. ),
  20. {
  21. className: 'keyword',
  22. variants: [
  23. {begin: '\\s*\\.end\\s[a-zA-Z0-9]*'},
  24. {begin: '^[ ]*\\.[a-zA-Z]*', relevance: 0},
  25. {begin: '\\s:[a-zA-Z_0-9]*', relevance: 0},
  26. {begin: '\\s(' + smali_keywords.join('|') + ')'}
  27. ]
  28. },
  29. {
  30. className: 'built_in',
  31. variants : [
  32. {
  33. begin: '\\s('+smali_instr_low_prio.join('|')+')\\s'
  34. },
  35. {
  36. begin: '\\s('+smali_instr_low_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)+\\s',
  37. relevance: 10
  38. },
  39. {
  40. begin: '\\s('+smali_instr_high_prio.join('|')+')((\\-|/)[a-zA-Z0-9]+)*\\s',
  41. relevance: 10
  42. },
  43. ]
  44. },
  45. {
  46. className: 'class',
  47. begin: 'L[^\(;:\n]*;',
  48. relevance: 0
  49. },
  50. {
  51. begin: '[vp][0-9]+',
  52. }
  53. ]
  54. };
  55. };