Skip to content

Commit cd5735a

Browse files
committed
增加对variable的部分支持
1 parent 78d08a9 commit cd5735a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to the "masm-tasm" extension will be documented in this file
88
- [ ] 问题匹配功能完善
99
- [ ] hover的简单实现:如中断的简单信息
1010
- [ ] LSP和DAP支持(目前对我来说太难了)
11+
- [ ] 根据具体的AH值显示跳转到不同的信息
1112

1213
### 0.1.4
1314

src/language/wordinfo.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as nls from 'vscode-nls'
44
const localize = nls.loadMessageBundle()
55

66
enum symboltype{
7-
macro,procedure,label,struct
7+
macro,procedure,struct,label,asmvar
88
}
99
class TasmSymbol{
1010
type:number
@@ -21,6 +21,7 @@ class TasmSymbol{
2121
let typestr:string=" "
2222
switch(this.type){
2323
case symboltype.label:typestr=localize("keykind.Label","label"); break;
24+
case symboltype.asmvar:typestr=localize("keykind.Variable","variable"); break;
2425
case symboltype.procedure:typestr=localize("keykind.Procedure","procedure"); break;
2526
case symboltype.struct:typestr=localize("keykind.Structure","Structure"); break;
2627
case symboltype.macro:typestr=localize("keykind.Macro","macro"); break;
@@ -30,13 +31,7 @@ class TasmSymbol{
3031
}
3132
}
3233
enum linetype{other,macro,endm,segment,ends,proc,endp}
33-
function readline(line:string){
34-
// let regmacro=/
35-
// let regendm
36-
// let regproc
37-
// let regendp=/
3834

39-
}
4035
export function findSymbol (word:string):TasmSymbol|undefined{
4136
for(let sym of symbols){
4237
if(sym.name===word){
@@ -46,6 +41,15 @@ export function findSymbol (word:string):TasmSymbol|undefined{
4641
return
4742
}
4843
const symbols:TasmSymbol[]=[]
44+
function scanline(line:string){
45+
let str=line.toLowerCase()
46+
if (str.includes("macro")) return linetype.macro
47+
if (str.includes("endm")) return linetype.endm
48+
if (str.includes("segment")) return linetype.segment
49+
if (str.includes("ends")) return linetype.ends
50+
if (str.includes("proc")) return linetype.proc
51+
if (str.includes("endp")) return linetype.endp
52+
}
4953
async function sacnDoc(document:string[],alsoVars : boolean = true) : Promise<number> {
5054
// scan the document for necessary information
5155
let labelreg=/^\s*(\w+)\s*:/
@@ -54,10 +58,17 @@ async function sacnDoc(document:string[],alsoVars : boolean = true) : Promise<nu
5458
let a=labelreg.exec(item)
5559
if(a){
5660
let name:string=a[1]
57-
let idx:number=a.index
61+
let idx:number=item.indexOf(a[1])
5862
let one:TasmSymbol=new TasmSymbol(symboltype.label,name,new vscode.Position(index,idx))
5963
symbols.push(one)
6064
}
65+
let b=item.match (/\s*(\w+)\s*[db|DB|dw|DW|dd|DD|df|DF|dq|DQ|dt|DT]/)
66+
if(b){
67+
let name:string=b[1]
68+
let idx:number=item.indexOf(b[1])
69+
let one:TasmSymbol=new TasmSymbol(symboltype.asmvar,name,new vscode.Position(index,idx))
70+
symbols.push(one)
71+
}
6172
},
6273
)
6374
return new Promise(resolve => {

0 commit comments

Comments
 (0)