Skip to content

Commit

Permalink
Adjusted cold-folding determination when seeing ORG* statements (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Apr 14, 2024
1 parent e0c7939 commit 6bdfb6e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion spin2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ Possible next additions:

Update P2 Only

- BUGFIX: Syntax: add missing bytefit/wordfit recodnition in DAT blocks
- BUGFIX: Syntax: add missing bytefit/wordfit recodnition in DAT blocks (#6)
- BUGFIX: Semantic: repair handling of {Spin2_v??} built-in method name support
- BUGFIX: File access issues on Windows (11?) repaired
- Cleaned up the code-fold detection... now handling ORG* forms better


## [2.2.15] 2024-04-09
Expand Down
2 changes: 1 addition & 1 deletion spin2/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isSpinOrPasmDocument } from './spin.vscode.utils';

let client: LanguageClient;

const isDebugLogEnabled: boolean = true; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit
const isDebugLogEnabled: boolean = false; // WARNING (REMOVE BEFORE FLIGHT)- change to 'false' - disable before commit
let debugOutputChannel: vscode.OutputChannel | undefined = undefined;

const objTreeProvider: ObjectTreeProvider = new ObjectTreeProvider();
Expand Down
17 changes: 17 additions & 0 deletions spin2/server/src/parser/spin.semantic.findings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ export class DocumentFindings {
foldEnd: { line: pasmCodeSpan.endLineIdx, character: Number.MAX_VALUE },
type: spanType
};
const pasmLineSpan: number = pasmCodeSpan.endLineIdx - pasmCodeSpan.startLineIdx + 1;
this._logMessage(` -- PASM block Ln#${pasmCodeSpan.startLineIdx + 1}-${pasmCodeSpan.endLineIdx + 1}(${pasmLineSpan}): [???]`);
foldingCodeSpans.push(nextSpan);
}

Expand All @@ -690,6 +692,10 @@ export class DocumentFindings {
foldEnd: { line: continuedLineSpan.endLineIdx, character: Number.MAX_VALUE },
type: eFoldSpanType.CodeBlock
};
const contLineSpan: number = continuedLineSpan.endLineIdx - continuedLineSpan.startLineIdx + 1;
this._logMessage(
` -- ContinuedLines block Ln#${continuedLineSpan.startLineIdx + 1}-${continuedLineSpan.endLineIdx + 1}(${contLineSpan}): [???]`
);
foldingCodeSpans.push(nextSpan);
}

Expand All @@ -701,6 +707,8 @@ export class DocumentFindings {
foldEnd: { line: spinFlowSpan.endLineIdx, character: Number.MAX_VALUE },
type: eFoldSpanType.CodeBlock
};
const flowLineSpan: number = spinFlowSpan.endLineIdx - spinFlowSpan.startLineIdx + 1;
this._logMessage(` -- FLOW block Ln#${spinFlowSpan.startLineIdx + 1}-${spinFlowSpan.endLineIdx + 1}(${flowLineSpan}): [???]`);
foldingCodeSpans.push(nextSpan);
}

Expand Down Expand Up @@ -1046,11 +1054,20 @@ export class DocumentFindings {
//
public recordPasmStart(lineIdx: number, isInline: boolean) {
// record the start lineIndex and type of pasm block
// handle multiple starts (don't nest)
if (this.isInPasmFold()) {
this.recordPasmEnd(lineIdx - 1);
}
this.pasmStartLineIdx = lineIdx;
this.pasmIsInline = isInline;
this._logMessage(` -- FND-PASM-NEW START lineIdx=[${lineIdx}], isInline=[${isInline}]`);
}

public isInPasmFold(): boolean {
// return T/F where T means we have a range in progress then...
return this.pasmStartLineIdx != -1 ? true : false;
}

public recordPasmEnd(lineIdx: number) {
// finish the pasm span record and record it
if (this.pasmStartLineIdx != -1) {
Expand Down
32 changes: 24 additions & 8 deletions spin2/server/src/parser/spin2.documentSemanticParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,15 @@ export class Spin2DocumentSemanticParser {
} else if (currState == eParseState.inDat) {
// process a class(static) variable line
this._logPASM(`- process DAT SECTION Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`);
if (trimmedNonCommentLine.length > 6 && trimmedNonCommentLine.toUpperCase().includes('ORG')) {
// the following 2 was 6 but skipping orgh statements???
if (trimmedNonCommentLine.length > 2 && trimmedNonCommentLine.toUpperCase().includes('ORG')) {
// ORG, ORGF, ORGH
const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedNonCommentLine);
this._logPASM(`- Ln#${lineNbr} pre-scan DAT trimmedNonCommentLine=[${trimmedNonCommentLine}], nonStringLine=[${nonStringLine}]`);
if (nonStringLine.toUpperCase().includes('ORG')) {
this._logPASM('- Ln#' + lineNbr + ' pre-scan DAT line trimmedLine=[' + trimmedLine + '] now Dat PASM');
this._logPASM(`- Ln#${lineNbr} pre-scan DAT line nonStringLine=[${nonStringLine}] now Dat PASM`);
// record start of PASM code NOT inline
this.semanticFindings.recordPasmStart(i, false);
this.semanticFindings.recordPasmStart(i, false); // false = NOT inline
prePAsmState = currState;
currState = eParseState.inDatPAsm;
this._getDAT_Declaration(0, lineNbr, line); // let's get possible label on this ORG statement
Expand Down Expand Up @@ -592,13 +594,14 @@ export class Spin2DocumentSemanticParser {
// process a data line
this._logPASM(`- check DAT Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`);
if (bHaveLineToProcess) {
if (trimmedLine.toUpperCase().includes('ORG')) {
if (trimmedNonCommentLine.toUpperCase().includes('ORG')) {
// ORG, ORGF, ORGH
const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedLine);
const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedNonCommentLine);
this._logPASM(`- Ln#${lineNbr} pre-scan DAT trimmedNonCommentLine=[${trimmedNonCommentLine}], nonStringLine=[${nonStringLine}]`);
if (nonStringLine.toUpperCase().includes('ORG')) {
this._logPASM(`- Ln#${lineNbr} pre-scan DAT line trimmedLine=[${trimmedLine}] now Dat PASM`);
// record start of PASM code NOT inline
this.semanticFindings.recordPasmStart(i, false);
this.semanticFindings.recordPasmStart(i, false); // false = NOT inline
prePAsmState = currState;
currState = eParseState.inDatPAsm;
this._getDAT_Declaration(0, lineNbr, line); // let's get possible label on this ORG statement
Expand Down Expand Up @@ -640,8 +643,21 @@ export class Spin2DocumentSemanticParser {
}
} else if (currState == eParseState.inDatPAsm) {
// process pasm (assembly) lines
this._logPASM(`- check DAT PASM Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`);
if (bHaveLineToProcess) {
this._logPASM(`- check DAT PASM Ln#${lineNbr} trimmedLine=[${trimmedLine}](${trimmedLine.length})`);
// the following 2 was 6 but skipping orgh statements???
if (trimmedNonCommentLine.length > 2 && trimmedNonCommentLine.toUpperCase().includes('ORG')) {
// ORG, ORGF, ORGH
const nonStringLine: string = this.parseUtils.removeDoubleQuotedStrings(trimmedNonCommentLine);
this._logPASM(`- Ln#${lineNbr} pre-scan DATpasm trimmedNonCommentLine=[${trimmedNonCommentLine}], nonStringLine=[${nonStringLine}]`);
if (nonStringLine.toUpperCase().includes('ORG')) {
this._logPASM(`- Ln#${lineNbr} pre-scan DATpasm line nonStringLine=[${nonStringLine}] now Dat PASM`);
// record start of PASM code NOT inline
this.semanticFindings.recordPasmStart(i, false); // false = NOT inline
this._getDAT_PAsmDeclaration(0, lineNbr, line); // let's get possible label on this ORG statement
continue;
}
}
this._getDAT_PAsmDeclaration(0, lineNbr, line);
const isDebugLine: boolean = haveDebugLine(trimmedNonCommentLine); // trimmedNonCommentLine.toLowerCase().includes("debug(");
if (isDebugLine) {
Expand All @@ -664,7 +680,7 @@ export class Spin2DocumentSemanticParser {
// Only ORG, not ORGF or ORGH
this._logPASM(`- Ln#${lineNbr} pre-scan PUB/PRI line trimmedLine=[${trimmedLineToParse}]`);
// record start of PASM code NOT inline
this.semanticFindings.recordPasmStart(i, true);
this.semanticFindings.recordPasmStart(i, true); // true = IS inline
prePAsmState = currState;
currState = eParseState.inPAsmInline;
// and ignore rest of this line
Expand Down

0 comments on commit 6bdfb6e

Please sign in to comment.