You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

2 months ago
  1. <!DOCTYPE html>
  2. <title>CodeMirror: WebAssembly mode</title>
  3. <meta charset="utf-8" />
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/mode/simple.js"></script>
  8. <script src="wast.js"></script>
  9. <style>
  10. .CodeMirror {
  11. border-top: 1px solid black;
  12. border-bottom: 1px solid black;
  13. }
  14. </style>
  15. <div id=nav>
  16. <a href="https://codemirror.net/5">
  17. <h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt="">
  18. </a>
  19. <ul>
  20. <li><a href="../../index.html">Home</a>
  21. <li><a href="../../doc/manual.html">Manual</a>
  22. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  23. </ul>
  24. <ul>
  25. <li><a href="../index.html">Language modes</a>
  26. <li><a class=active href="#">WebAssembly</a>
  27. </ul>
  28. </div>
  29. <article>
  30. <h2>WebAssembly mode</h2>
  31. <div><textarea id="code" name="code">
  32. /* Example WebAssembly */
  33. (module $foo
  34. (export "fac" (func $fac))
  35. (export "plus" (func $plus))
  36. (func $fac (type $t0) (param $p0 i64) (result i64)
  37. (if $I0 (result i64)
  38. (i64.lt_s
  39. (local.get $p0)
  40. (i64.const 1))
  41. (then
  42. (i64.const 1))
  43. (else
  44. (i64.mul
  45. (local.get $p0)
  46. (call $fac
  47. (i64.sub
  48. (local.get $p0)
  49. (i64.const 1)))))))
  50. (func $plus (param $x i32) (param $y i32) (result i32)
  51. (i32.add
  52. (local.get $x)
  53. (local.get $y))))</textarea></div>
  54. <script>
  55. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  56. lineNumbers: true,
  57. lineWrapping: true,
  58. indentUnit: 4,
  59. mode: "wast"
  60. });
  61. </script>
  62. <p><strong>MIME types defined:</strong> <code>text/webassembly</code>.</p>
  63. </article>