|
133 | 133 | result.parentNode.style.visibility = "";
|
134 | 134 | }
|
135 | 135 |
|
136 |
| - function evaluate(result, code, version, optimize, button, test) { |
137 |
| - send("evaluate.json", {code: code, version: version, optimize: optimize, test: !!test, separate_output: true, color: true}, |
| 136 | + function evaluate(result, code, version, optimize, button, test, backtrace) { |
| 137 | + send("evaluate.json", {code: code, version: version, optimize: optimize, test: !!test, separate_output: true, color: true, backtrace: backtrace }, |
138 | 138 | function(object) {
|
139 | 139 | var samp, pre;
|
140 | 140 | set_result(result);
|
|
174 | 174 | }, button, test ? "Running tests…" : "Running…", result);
|
175 | 175 | }
|
176 | 176 |
|
177 |
| - function compile(emit, result, code, version, optimize, button) { |
| 177 | + function compile(emit, result, code, version, optimize, button, backtrace) { |
178 | 178 | var syntax = document.getElementById('asm-flavor').value;
|
179 | 179 | send("compile.json", {emit: emit, code: code, version: version, optimize: optimize,
|
180 |
| - color: true, highlight: true, syntax: syntax}, function(object) { |
| 180 | + color: true, highlight: true, syntax: syntax, backtrace: backtrace}, function(object) { |
181 | 181 | if ("error" in object) {
|
182 | 182 | set_result(result, "<pre class=\"rustc-output rustc-errors\"><samp></samp></pre>");
|
183 | 183 | result.firstChild.firstChild.innerHTML = formatCompilerOutput(object.error);
|
|
233 | 233 | result.parentNode.style.visibility = "";
|
234 | 234 | }
|
235 | 235 |
|
236 |
| - function shareGist(result, version, code, button) { |
| 236 | + function shareGist(result, version, code, button, backtraceval) { |
237 | 237 | // only needed for the "shrinking" animation
|
238 | 238 | var full_url = "https://play.rust-lang.org/?code=" + encodeURIComponent(code) +
|
239 |
| - "&version=" + encodeURIComponent(version); |
| 239 | + "&version=" + encodeURIComponent(version) + |
| 240 | + "&backtrace=" + encodeURIComponent(backtraceval); |
240 | 241 | var url = "https://api.github.com/gists";
|
241 | 242 | button.disabled = true;
|
242 | 243 |
|
|
275 | 276 |
|
276 | 277 | var play_url = "https://play.rust-lang.org/?gist=" +
|
277 | 278 | encodeURIComponent(gist_id) + "&version=" +
|
278 |
| - encodeURIComponent(version); |
| 279 | + encodeURIComponent(version) + |
| 280 | + "&backtrace=" + encodeURIComponent(backtraceval); |
279 | 281 |
|
280 | 282 |
|
281 | 283 | var link = result.firstChild.firstElementChild;
|
|
301 | 303 | );
|
302 | 304 | }
|
303 | 305 |
|
304 |
| - function share(result, version, code, button) { |
| 306 | + function share(result, version, code, button, backtraceval) { |
305 | 307 | var playurl = "https://play.rust-lang.org/?code=" + encodeURIComponent(code);
|
306 | 308 | playurl += "&version=" + encodeURIComponent(version);
|
| 309 | + playurl += "&backtrace=" + encodeURIComponent(backtraceval); |
307 | 310 | if (playurl.length > 5000) {
|
308 | 311 | set_result(result, "<p class=error>Sorry, your code is too long to share this way." +
|
309 | 312 | "<p class=error-explanation>At present, sharing produces a link containing the" +
|
|
482 | 485 | var mode;
|
483 | 486 | var query;
|
484 | 487 | var asm_flavor;
|
| 488 | + var backtrace; |
485 | 489 |
|
486 | 490 | function updateEvaluateAction(code) {
|
487 | 491 | // A very simple pair of heuristics; there’s no point in doing more, IMO.
|
|
503 | 507 | }
|
504 | 508 | evaluate(result, session.getValue(), getRadioValue("version"),
|
505 | 509 | getRadioValue("optimize"), evaluateButton,
|
506 |
| - evaluateAction === "test"); |
| 510 | + evaluateAction === "test", |
| 511 | + backtrace.value); |
507 | 512 | }
|
508 | 513 |
|
509 | 514 | var COLOR_CODES = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
|
|
552 | 557 | clearResultButton = document.getElementById("clear-result");
|
553 | 558 | keyboard = document.getElementById("keyboard");
|
554 | 559 | asm_flavor = document.getElementById("asm-flavor");
|
| 560 | + backtrace = document.getElementById("backtrace"); |
555 | 561 | themes = document.getElementById("themes");
|
556 | 562 | editor = ace.edit("editor");
|
557 | 563 | set_result.editor = editor;
|
|
589 | 595 | asm_flavor.value = flavor;
|
590 | 596 | }
|
591 | 597 |
|
| 598 | + var vbacktrace = optionalLocalStorageGetItem("backtrace"); |
| 599 | + if (vbacktrace !== null) { |
| 600 | + backtrace.value = vbacktrace; |
| 601 | + } |
| 602 | + |
592 | 603 | query = getQueryParameters();
|
593 | 604 | if ("code" in query) {
|
594 | 605 | session.setValue(query.code);
|
|
610 | 621 | }
|
611 | 622 | }
|
612 | 623 |
|
| 624 | + if ("backtrace" in query) { |
| 625 | + if (backtrace !== null) { |
| 626 | + backtrace.value = query.backtrace; |
| 627 | + } |
| 628 | + } |
| 629 | + |
613 | 630 | if (query.run === "1") {
|
614 | 631 | doEvaluate();
|
615 | 632 | } else {
|
|
637 | 654 | optionalLocalStorageSetItem("asm_flavor", flavor);
|
638 | 655 | };
|
639 | 656 |
|
| 657 | + backtrace.onkeyup = backtrace.onchange = function() { |
| 658 | + var vbacktrace = backtrace.options[backtrace.selectedIndex].value; |
| 659 | + optionalLocalStorageSetItem("backtrace", vbacktrace); |
| 660 | + }; |
| 661 | + |
640 | 662 | evaluateButton.onclick = function() {
|
641 | 663 | doEvaluate(true);
|
642 | 664 | };
|
|
656 | 678 |
|
657 | 679 | asmButton.onclick = function() {
|
658 | 680 | compile("asm", result, session.getValue(), getRadioValue("version"),
|
659 |
| - getRadioValue("optimize"), asmButton); |
| 681 | + getRadioValue("optimize"), asmButton, backtrace.value); |
660 | 682 | };
|
661 | 683 |
|
662 | 684 | irButton.onclick = function() {
|
663 | 685 | compile("llvm-ir", result, session.getValue(), getRadioValue("version"),
|
664 |
| - getRadioValue("optimize"), irButton); |
| 686 | + getRadioValue("optimize"), irButton, backtrace.value); |
665 | 687 | };
|
666 | 688 |
|
667 | 689 | mirButton.onclick = function() {
|
668 | 690 | document.getElementById("version-nightly").checked = true;
|
669 | 691 | compile("mir", result, session.getValue(), getRadioValue("version"),
|
670 |
| - getRadioValue("optimize"), mirButton); |
| 692 | + getRadioValue("optimize"), mirButton, backtrace.value); |
671 | 693 | };
|
672 | 694 |
|
673 | 695 | formatButton.onclick = function() {
|
674 | 696 | format(result, session, getRadioValue("version"), formatButton);
|
675 | 697 | };
|
676 | 698 |
|
677 | 699 | shareButton.onclick = function() {
|
678 |
| - share(result, getRadioValue("version"), session.getValue(), shareButton); |
| 700 | + share(result, getRadioValue("version"), session.getValue(), shareButton, backtrace.value); |
679 | 701 | };
|
680 | 702 |
|
681 | 703 | gistButton.onclick = function() {
|
682 |
| - shareGist(result, getRadioValue("version"), session.getValue(), gistButton); |
| 704 | + shareGist(result, getRadioValue("version"), session.getValue(), gistButton, backtrace.value); |
683 | 705 | };
|
684 | 706 |
|
685 | 707 | configureEditorButton.onclick = function() {
|
|
0 commit comments