Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Warn when assembly output is in AT&T syntax (#4311)#8272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sean-garwood wants to merge1 commit intocompiler-explorer:main
base:main
Choose a base branch
Loading
fromsean-garwood:fix-att-syntax-tooltip
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsCONTRIBUTORS.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,3 +170,4 @@ From oldest to newest contributor, we would like to thank:
- [LJ](https://github.com/elle-j)
- [Frank Leon Rose](https://github.com/frankleonrose)
- [Oguz Ulgen](https://github.com/oulgen)
- [Sean Garwood](https://github.com/sean-garwood)
27 changes: 27 additions & 0 deletionsstatic/assembly-syntax.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2025, Compiler Explorer Authors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

export const AssemblySyntaxesList = ['att', 'intel'] as const;

export type AssemblySyntax = (typeof AssemblySyntaxesList)[number];
46 changes: 41 additions & 5 deletionsstatic/panes/compiler.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -82,6 +82,7 @@ import {InstructionSet} from '../../types/instructionsets.js';
import {LanguageKey} from '../../types/languages.interfaces.js';
import {Tool} from '../../types/tool.interfaces.js';
import {ArtifactHandler} from '../artifact-handler.js';
import {AssemblySyntax} from '../assembly-syntax.js';
import {ICompilerShared} from '../compiler-shared.interfaces.js';
import {CompilerShared} from '../compiler-shared.js';
import {SourceAndFiles} from '../download-service.js';
Expand DownExpand Up@@ -143,7 +144,10 @@ type Assembly = {

const COMPILING_PLACEHOLDER = '<Compiling...>';

// Disable max line count only for the constructor. Turns out, it needs to do quite a lot of things
// Disable max line count only for the constructor. Turns out, it needs to do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

was there a reason to reformat this line?

// quite a lot of things

const attSyntaxWarning = '***WARNING: The information shown pertains to Intel syntax.***';

export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, CompilerState> {
private compilerService: CompilerService;
Expand DownExpand Up@@ -2809,6 +2813,12 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
);
}

asmSyntax(): AssemblySyntax {
return this.compiler?.supportsIntel && this.filters.isSet('intel') && this.compiler.intelAsm.includes('intel')
? 'intel'
: 'att';
}

handlePopularArgumentsResult(result: Record<string, {description: string}> | null): void {
const popularArgumentsMenu = $(this.domRoot.find('div.populararguments div.dropdown-menu'));

Expand DownExpand Up@@ -3464,19 +3474,37 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
public static async getAsmInfo(
opcode: string,
instructionSet: InstructionSet,
syntax: AssemblySyntax = 'intel',
): Promise<AssemblyInstructionInfo | undefined> {
const cacheName = `asm/${instructionSet}/${opcode}`;
const cached = OpcodeCache.get(cacheName);

// Helper to add AT&T syntax warning to opcode data without mutating cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice solution to this.

const addAttWarningIfNeeded = (data: AssemblyInstructionInfo): AssemblyInstructionInfo => {
if (syntax === 'att') {
return {
...data,
tooltip: attSyntaxWarning + '\n\n' + data.tooltip,
html: attSyntaxWarning + '<br><br>' + data.html,
};
}
return data;
};

if (cached) {
if (cached.found) return cached.data as AssemblyInstructionInfo;
if (cached.found) {
const cachedData = cached.data as AssemblyInstructionInfo;
// Return a copy with warnings added based on current syntax mode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not sure this comment adds anything - the function name is very descriptive. Justreturn addAttWEarningIfNeeded(cached.datat as AssmeblyInstructionIfo); just as you do below.

return addAttWarningIfNeeded(cachedData);
}
throw new Error(cached.data as string);
}

const response = await getAssemblyDocumentation({opcode, instructionSet});
const body = await response.json();
if (response.status === 200) {
OpcodeCache.set(cacheName, {found: true, data: body});
return body;
returnaddAttWarningIfNeeded(body);
}
const error = (body as any).error;
OpcodeCache.set(cacheName, {found: false, data: error});
Expand DownExpand Up@@ -3585,6 +3613,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
const response = await Compiler.getAsmInfo(
currentWord.word,
unwrap(this.recentInstructionSet || this.compiler.instructionSet),
this.asmSyntax(),
);
if (!response) return;
this.decorations.asmToolTip = [
Expand DownExpand Up@@ -3641,12 +3670,13 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
);
}

function appendInfo(url: string): string {
function appendInfo(url: string, syntax: AssemblySyntax): string {
return (
'<br><br>For more information, visit <a href="' +
url +
'" target="_blank" rel="noopener noreferrer">the ' +
opcode +
(syntax === 'att' ? syntaxWarning() : '') +
' documentation <sup><small class="fas fa-external-link-alt opens-new-window"' +
' title="Opens in a new window"></small></sup></a>.' +
'<br>If the documentation for this opcode is wrong or broken in some way, ' +
Expand All@@ -3658,14 +3688,20 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
);
}

function syntaxWarning(): string {
return `<br><br><b>${attSyntaxWarning}</b>`;
}

try {
if (this.compiler?.supportsAsmDocs) {
const asmSyntax = this.asmSyntax();
const asmHelp = await Compiler.getAsmInfo(
word.word,
unwrap(this.recentInstructionSet || this.compiler.instructionSet),
asmSyntax,
);
if (asmHelp) {
this.alertSystem.alert(opcode + ' help', asmHelp.html + appendInfo(asmHelp.url), {
this.alertSystem.alert(opcode + ' help', asmHelp.html + appendInfo(asmHelp.url, asmSyntax), {
onClose: () => {
ed.focus();
ed.setPosition(pos);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp