Skip to content

Commit

Permalink
preserve latest debug vs debug() and coginit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Dec 8, 2022
1 parent e9671dc commit a047145
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 44 deletions.
3 changes: 3 additions & 0 deletions spin2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Update Spin2 highlighting (syntax and/or semantic parser fixes)
- Spin2: Recognize non-float decimal numbers with exponents
- Spin2: Recognize `debug_main` and `debug_coginit` compile time directives
- Spin2: Recognize event names in pasm2 correctly
- Spin2: Fix cases where 'debug' used without parenthesis causes extension crash
- Spin2: Recognize coginit constants (some pasm2 cases were being missed)
- Spin2: Add recognition of LutColors directive in debug statements with run-time termainal assignment

**NOTE:** *There is no change in our "Known Issues" list for this release.*

Expand Down
58 changes: 30 additions & 28 deletions spin2/TEST/PNut_v37_files.taskpaper
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
Spin/Spin2 files in FOLDER:
Root /Users/stephen/Dropbox/PropV2-Shared/P2-withPNut:
PNut_v37_files:

001-1: PNut_v37_files:
- ADC_to_VGA_millivolts.spin2 [1,1]
- EVENT not recognized: _ret_ setint1 #event_se1
Root /Users/stephen/Dropbox/PropV2-Shared/P2-withPNut:
PNut_v37_files:
001-1: PNut_v37_files:
- ADC_to_VGA_millivolts.spin2 [1,1] @done(2022-12-07)
- EVENT not recognized: _ret_ setint1 #event_se1 @done(2022-12-07)
- blink.spin2 [2,1] @done(2022-12-02)
- Chorus.spin2 [3,1] @done(2022-12-02)
- Chorus_Crossfade_Pitchbend.spin2 [4,1]
- form of debug() not hightlighted correctly (diff string types)
- form of debug() not hightlighted correctly (diff string types) NO FIX
- Chorus_Simple_Pitchbend.spin2 [5,1]
- form of debug() not hightlighted correctly (diff string types)
- form of debug() not hightlighted correctly (diff string types) NO FIX
- clock_setter.spin2 [6,1] @done(2022-12-02)
- DEBUG_BITMAP_HSV16_Demo.spin2 [7,1] @done(2022-12-02)
- DEBUG_BITMAP_RGB24_Demo.spin2 [8,1]
- RED lutcolors!
- DEBUG_BITMAP_RGB24_Demo.spin2 [8,1] @done(2022-12-07)
- RED lutcolors! @done(2022-12-07)
- DEBUG_demo.spin2 [9,1] @done(2022-12-02)
- DEBUG_Mouse_and_Keyboard.spin2 [10,1]
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??)
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??) NO FIX
- DEBUG_PLOT_HubRAM.spin2 [11,1]
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??)
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??) NO FIX
- DEBUG_PLOT_Sprites.spin2 [12,1]
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??)
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??) NO FIX
- debugger_clock_frequency_change.spin2 [13,1] @done(2022-12-02)
- debugger_demo.spin2 [14,1]
- label on debug line missed!
- .label missed!
- PUB signature missed?!
- debugger_single_step.spin2 [15,1]
- debug_main directive?
- Five_Buttons_One_Pin.spin2 [16,1]
- EVENT not recognized: _ret_ setint3 #event_se1
- debugger_demo.spin2 [14,1] @done(2022-12-07)
- label on debug line missed! @done(2022-12-07)
- .label missed! @done(2022-12-07)
- PUB signature missed?! @done(2022-12-07)
- debugger_single_step.spin2 [15,1] @done(2022-12-07)
- debug_main directive? @done(2022-12-07)
- Five_Buttons_One_Pin.spin2 [16,1] @done(2022-12-07)
- EVENT not recognized: _ret_ setint3 #event_se1 @done(2022-12-07)
- flash_loader.spin2 [17,1] @done(2022-12-02)
- floating_point_demo.spin2 [18,1] @done(2022-12-02)
- Goertzel_DEBUG_Demo.spin2 [19,1] @done(2022-12-02)
Expand All @@ -40,28 +40,30 @@ Spin/Spin2 files in FOLDER:
- HDTV_1920x1080_text_135x160.spin2 [23,1] @done(2022-12-02)
- HDTV_1920x1080_text_240x90.spin2 [24,1] @done(2022-12-02)
- headphones.spin2 [25,1]
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??)
- CON missing so top lines not hightlighed (?? how to do this in syntax processing? or override in Semantic processing ??) NO FIX
- hubexec_from_spin2.spin2 [26,1] @done(2022-12-02)
- inline_pasm.spin2 [27,1] @done(2022-12-02)
- NTSC_256_x_192.spin2 [28,1] @done(2022-12-02)
- NTSC_256_x_192_interrupt.spin2 [29,1] @done(2022-12-02)
- NTSC_PAL.spin2 [30,1] @done(2022-12-02)
- NTSC_PAL_4bpp_interrupt.spin2 [31,1]
- debug() messing highlight of variable-label from DAT : debug(udec(pm,px),uhex(#pn_))
- debug() messing highlight of variable-label from DAT : debug(udec(pm,px),uhex(#pn_)) NO FIX
- NTSC_PAL_4bpp_interrupt_Demo.spin2 [32,1] @done(2022-12-02)
- NTSC_PAL_Demo.spin2 [33,1] @done(2022-12-02)
- parser.spin2 [34,1]
- missing highlight on long and |m name use in DAT table (|m is sometimes white, while long is sometimes red)
- Spin2_debugger.spin2 [35,1]
- bad float value hightlight!!!
- Spin2_interpreter.spin2 [36,1]
- RED hubexec as literal: coginit #hubexec,##launch_spin
- bad float value hightlight!!! @done(2022-12-07)
- mocz _clr (_clr not defined!) shouldn't compile!!!
- Spin2_interpreter.spin2 [36,1] @done(2022-12-07)
- RED hubexec as literal: coginit #hubexec,##launch_spin @done(2022-12-07)
- VGA_1280x1024_text_160x85.spin2 [37,1] @done(2022-12-02)
- VGA_640x480_text_80x40.spin2 [38,1] @done(2022-12-02)
- vga_text_demo.spin2 [39,1] @done(2022-12-02)

Stats for FOLDER:
Root /Users/stephen/Dropbox/PropV2-Shared/P2-withPNut:
PNut_v37_files:
Root /Users/stephen/Dropbox/PropV2-Shared/P2-withPNut:
PNut_v37_files:
1 directories containing:
39 Unique filenames
(39 Unique files where content is diff.)
Expand Down
38 changes: 38 additions & 0 deletions spin2/TEST/spin2/221206-fixes.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,41 @@ ma_adpcm_bufferbase long @adpcm_buffers

adpcm_buffers
' -----------------------------------------------------------------
DAT
org

setq dbase_init 'restart cog 0 with interpreter
coginit #hubexec,##launch_spin

dbase_init long 320_000_000 '$38 - compiler supplies initial dbase value
'
' Unaligned data
'
orgh

DAT
org
launch_spin loc ptrb,#\$80000 'point to zeroes in empty hub space

' -----------------------------------------------------------------
CON _clkfreq = 200_000_000

'debug_main 'uncomment to single-step through everything, even COGINITs
'debug_coginit 'uncomment to break on COGINITs

PUB go() | i

coginit(newcog, @pasm_program,0) 'start another cog with a PASM program (another debugger will open)

repeat 'keep looping while incrementing a variable
i++
debug 'break everytime through the loop if "DEBUG" is selected (default)

DAT org

pasm_program debug 'do a DEBUG at the start of the program to open debugger
.loop add pa,#1 'select "MAIN" in the debugger to single-step
sub pb,#2
jmp #.loop

long 0[12] 'fill with some NOP's to make it easy to see the code above
54 changes: 38 additions & 16 deletions spin2/src/spin2.semanticAndOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
// handle name in 1 column
const firstName: string = lineParts.length > 0 ? lineParts[0] : "";
const secondName: string = lineParts.length > 1 ? lineParts[1] : "";
const bIsAlsoDebugLine: boolean = firstName.toLowerCase() == "debug" || secondName.toLowerCase() == "debug" ? true : false;
const bIsAlsoDebugLine: boolean = inLinePasmRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false;
if (bIsAlsoDebugLine) {
const partialTokenSet: IParsedToken[] = this._reportDebugStatement(lineNumber, startingOffset, line);
partialTokenSet.forEach((newToken) => {
Expand Down Expand Up @@ -1569,6 +1569,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
!this._isPasmConditional(namePart) &&
!this._isBinaryOperator(namePart) &&
!this._isBuiltinReservedWord(namePart) &&
!this._isCoginitReservedSymbol(namePart) &&
!this._isDebugMethod(namePart) &&
!bIsAlsoDebugLine
) {
Expand Down Expand Up @@ -2073,7 +2074,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
//}
this._logSPIN(" -- possNames=[" + possNames + "]");
const firstName: string = possNames.length > 0 ? possNames[0] : "";
const bIsDebugLine: boolean = firstName.toLowerCase() == "debug" ? true : false;
const bIsDebugLine: boolean = nonStringAssignmentRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false;
for (let index = 0; index < possNames.length; index++) {
let possibleName = possNames[index];
// special code to handle case of var.[bitfield] leaving name a 'var.'
Expand Down Expand Up @@ -2129,7 +2130,15 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
});
}
// we use bIsDebugLine in next line so we don't flag debug() arguments!
else if (!this._isSpinReservedWord(namePart) && !this._isSpinBuiltinMethod(namePart) && !this._isBuiltinReservedWord(namePart) && !this._isDebugMethod(namePart) && !bIsDebugLine) {
else if (
!this._isSpinReservedWord(namePart) &&
!this._isSpinBuiltinMethod(namePart) &&
!this._isBuiltinReservedWord(namePart) &&
!this._isCoginitReservedSymbol(namePart) &&
!this._isDebugMethod(namePart) &&
!bIsDebugLine &&
!this._isDebugInvocation(namePart)
) {
// NO DEBUG FOR ELSE, most of spin control elements come through here!
//else {
// this._logSPIN(' -- UNKNOWN?? name=[' + namePart + '] - name-get-breakage??');
Expand Down Expand Up @@ -2207,7 +2216,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
this._logPASM(" -- reportInLinePasmDecl lineParts=[" + lineParts + "]");
const firstName: string = lineParts.length > 0 ? lineParts[0] : "";
const secondName: string = lineParts.length > 1 ? lineParts[1] : "";
const bIsAlsoDebugLine: boolean = firstName.toLowerCase() == "debug" || secondName.toLowerCase() == "debug" ? true : false;
const bIsAlsoDebugLine: boolean = inLinePasmRHSStr.toLowerCase().indexOf("debug(") != -1 ? true : false;
if (bIsAlsoDebugLine) {
const partialTokenSet: IParsedToken[] = this._reportDebugStatement(lineNumber, startingOffset, line);
partialTokenSet.forEach((newToken) => {
Expand Down Expand Up @@ -2599,6 +2608,9 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
// get line parts - we only care about first one
const debugStatementStr = this._getDebugStatement(currentOffset, line);
this._logDEBUG(" -- rptDbg debugStatementStr=[" + debugStatementStr + "]");
if (debugStatementStr.length == 0) {
return tokenSet;
}
// now record the comment if we have one
const commentRHSStrOffset: number = currentOffset + debugStatementStr.length;
const commentOffset: number = line.indexOf("'", commentRHSStrOffset);
Expand Down Expand Up @@ -2721,7 +2733,6 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
!this._isSpinBuiltinMethod(newParameter) &&
!this._isBuiltinReservedWord(newParameter)
) {
// 1 xyzzy
this._logDEBUG(" -- rptDbg 1 unkParam=[" + newParameter + "]");
tokenSet.push({
line: lineNumber,
Expand Down Expand Up @@ -2803,7 +2814,10 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
}
symbolOffset = line.indexOf(newParameter, symbolOffset);
this._logDEBUG(" -- rptDbg ?check? [" + newParameter + "] symbolOffset=" + symbolOffset);
const bIsParameterName: boolean = this._isNameWithTypeFeed(newParameter, eDisplayType);
let bIsParameterName: boolean = this._isNameWithTypeFeed(newParameter, eDisplayType);
if (isRuntimeNamed && newParameter.toLowerCase() == "lutcolors") {
bIsParameterName = true;
}
if (bIsParameterName) {
this._logDEBUG(" -- rptDbg newParam=[" + newParameter + "]");
tokenSet.push({
Expand Down Expand Up @@ -2848,7 +2862,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
});
} else {
// handle unknown-name case
const paramIsSymbolName: boolean = newParameter.substring(0, 1).match(/[a-zA-Z_]/) ? true : false; // 2 xyzzy
const paramIsSymbolName: boolean = newParameter.substring(0, 1).match(/[a-zA-Z_]/) ? true : false;
if (
paramIsSymbolName &&
this._isDebugMethod(newParameter) == false &&
Expand All @@ -2859,7 +2873,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
!this._isSpinBuiltinMethod(newParameter) &&
!this._isBuiltinReservedWord(newParameter)
) {
this._logDEBUG(" -- rptDbg 2 unkParam=[" + newParameter + "]");
this._logDEBUG(" -- rptDbg 2 unkParam=[" + newParameter + "]"); // XYZZY LutColors
tokenSet.push({
line: lineNumber,
startCharacter: symbolOffset,
Expand Down Expand Up @@ -2924,7 +2938,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
});
} else {
// handle unknown-name case
const paramIsSymbolName: boolean = newParameter.substring(0, 1).match(/[a-zA-Z_]/) ? true : false; // 3 xyzzy
const paramIsSymbolName: boolean = newParameter.substring(0, 1).match(/[a-zA-Z_]/) ? true : false;
if (
paramIsSymbolName &&
!this._isDebugMethod(newParameter) &&
Expand Down Expand Up @@ -4204,6 +4218,7 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
// debug overridable CONSTANTS
"debug_main",
"debug_coginit",
"debug",
];
const reservedStatus: boolean = debugExec.indexOf(name.toLowerCase()) != -1;
return reservedStatus;
Expand Down Expand Up @@ -4302,6 +4317,18 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
"posx",
"negx",
"pi",
];
let reservedStatus: boolean = spinInstructionsOfNote.indexOf(name.toLowerCase()) != -1;
if (reservedStatus == false) {
reservedStatus = this._isBinaryOperator(name);
}
if (reservedStatus == false) {
reservedStatus = this._isUnaryOperator(name);
}
return reservedStatus;
}
private _isCoginitReservedSymbol(name: string): boolean {
const coginitSymbolOfNote: string[] = [
//
"newcog",
"cogexec",
Expand All @@ -4311,15 +4338,10 @@ export class Spin2DocumentSemanticTokensProvider implements vscode.DocumentSeman
"cogexec_new_pair",
"hubexec_new_pair",
];
let reservedStatus: boolean = spinInstructionsOfNote.indexOf(name.toLowerCase()) != -1;
if (reservedStatus == false) {
reservedStatus = this._isBinaryOperator(name);
}
if (reservedStatus == false) {
reservedStatus = this._isUnaryOperator(name);
}
const reservedStatus: boolean = coginitSymbolOfNote.indexOf(name.toLowerCase()) != -1;
return reservedStatus;
}

private _isBinaryOperator(name: string): boolean {
const binaryOperationsOfNote: string[] = ["sar", "ror", "rol", "rev", "zerox", "signx", "sca", "scas", "frac", "addbits", "addpins", "and", "or", "xor"];
const reservedStatus: boolean = binaryOperationsOfNote.indexOf(name.toLowerCase()) != -1;
Expand Down
9 changes: 9 additions & 0 deletions spin2/syntaxes/spin2.tmLanguage.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ repository:
cog_register_names:
name: constant.language.cog-register-names.spin2
match: '(?i)\b(PR(0|1|2|3|4|5|6|7)|IJMP(1|2|3)|IRET(1|2|3)|P(A|B)|PTR(A|B)|DIR(A|B)|IN(A|B)|OUT(A|B))\b'
coginit_constants:
name: constant.language.coginit.names.spin2
match: '(?i)\b((COG|HUB)EXEC(_NEW|NEW_PAIR)?)\b'
comment:
patterns:
-
Expand Down Expand Up @@ -215,6 +218,8 @@ repository:
include: '#number'
-
include: '#string'
-
include: '#coginit_constants'
-
include: '#debug_functions'
-
Expand All @@ -241,6 +246,8 @@ repository:
include: '#streamer_constants'
-
include: '#cog_register_names'
-
include: '#coginit_constants'
-
name: storage.modifier.pasm2
match: '(?i)\b(ORG(F|H)?|FIT)\b'
Expand Down Expand Up @@ -436,6 +443,8 @@ repository:
include: '#streamer_constants'
-
include: '#cog_register_names'
-
include: '#coginit_constants'
-
name: storage.type.pasm.spin2
match: '(?i)\b(BYTE|WORD|BYTEFIT|WORDFIT|LONG)\b'
Expand Down
13 changes: 13 additions & 0 deletions spin2/syntaxes/spin2.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
"name": "constant.language.cog-register-names.spin2",
"match": "(?i)\\b(PR(0|1|2|3|4|5|6|7)|IJMP(1|2|3)|IRET(1|2|3)|P(A|B)|PTR(A|B)|DIR(A|B)|IN(A|B)|OUT(A|B))\\b"
},
"coginit_constants": {
"name": "constant.language.coginit.names.spin2",
"match": "(?i)\\b((COG|HUB)EXEC(_NEW|NEW_PAIR)?)\\b"
},
"comment": {
"patterns": [
{
Expand Down Expand Up @@ -332,6 +336,9 @@
{
"include": "#string"
},
{
"include": "#coginit_constants"
},
{
"include": "#debug_functions"
},
Expand Down Expand Up @@ -371,6 +378,9 @@
{
"include": "#cog_register_names"
},
{
"include": "#coginit_constants"
},
{
"name": "storage.modifier.pasm2",
"match": "(?i)\\b(ORG(F|H)?|FIT)\\b"
Expand Down Expand Up @@ -649,6 +659,9 @@
{
"include": "#cog_register_names"
},
{
"include": "#coginit_constants"
},
{
"name": "storage.type.pasm.spin2",
"match": "(?i)\\b(BYTE|WORD|BYTEFIT|WORDFIT|LONG)\\b"
Expand Down

0 comments on commit a047145

Please sign in to comment.