1- import { window , Terminal , Uri , TextDocument } from 'vscode'
1+ import { window , Terminal , Uri , TextDocument } from 'vscode' ;
22import { Config } from './configration' ;
3- import { exec } from 'child_process'
4- import { DOSBox } from './DOSBox'
5- import { landiagnose } from './language/diagnose'
3+ import { exec } from 'child_process' ;
4+ import { DOSBox } from './DOSBox' ;
5+ import { AssemblerDiag } from './language/diagnose' ;
66import * as nls from 'vscode-nls' ;
7- const localize = nls . loadMessageBundle ( )
7+ const localize = nls . loadMessageBundle ( ) ;
88export class MSDOSplayer {
9- private _terminal : Terminal | null
9+ private _terminal : Terminal | null ;
1010 constructor ( ) {
11- this . _terminal = null
11+ this . _terminal = null ;
1212 }
1313 /**
1414 * 使用msdos-player执行汇编链接,如果汇编成功执行运行或者调试,如果失败输出错误信息
@@ -18,39 +18,39 @@ export class MSDOSplayer {
1818 * @param diag 处理输出信息的类,如果有将使用diag.ErrMsgProcess处理错误信息
1919 * @param doc 需要处理的文件
2020 */
21- public PlayerASM ( conf : Config , isrun : boolean , viaplayer : boolean , diag : landiagnose , doc : TextDocument ) {
22- let filecontent : string
23- filecontent = doc . getText ( )
24- const filename = doc . fileName
25- let command = '"' + conf . msbatpath + '" "' + conf . path + '" ' + conf . MASMorTASM + ' "' + filename + '" "' + conf . workpath + '"'
21+ public PlayerASM ( conf : Config , isrun : boolean , viaplayer : boolean , diag : AssemblerDiag , doc : TextDocument ) {
22+ let filecontent : string ;
23+ filecontent = doc . getText ( ) ;
24+ const filename = doc . fileName ;
25+ let command = '"' + conf . msbatpath + '" "' + conf . path + '" ' + conf . MASMorTASM + ' "' + filename + '" "' + conf . workpath + '"' ;
2626 exec ( command , { cwd : conf . path , shell : 'cmd.exe' } , ( error , stdout , stderr ) => {
2727 if ( error ) { console . error ( `exec playerasm.bat: ${ error } ` ) ; }
28- let code = diag . ErrMsgProcess ( filecontent , stdout , doc . uri , conf . MASMorTASM )
28+ let code = diag . ErrMsgProcess ( filecontent , stdout , doc . uri , conf . MASMorTASM ) ;
2929 switch ( code ) {
3030 case 0 :
31- let Errmsgwindow = localize ( "msdos.error" , "{0} Error,Can't generate .exe file" , conf . MASMorTASM )
31+ let Errmsgwindow = localize ( "msdos.error" , "{0} Error,Can't generate .exe file" , conf . MASMorTASM ) ;
3232 window . showErrorMessage ( Errmsgwindow ) ;
33- break
33+ break ;
3434 case 1 :
3535 let warningmsgwindow = localize ( "msdos.warn" , "{0} Warning,successfully generate .exe file,but assembler has some warning message" , conf . MASMorTASM ) ;
36- let Go_on = localize ( "msdos.continue" , "continue" )
37- let Stop = localize ( "msdos.stop" , "stop" )
36+ let Go_on = localize ( "msdos.continue" , "continue" ) ;
37+ let Stop = localize ( "msdos.stop" , "stop" ) ;
3838 window . showInformationMessage ( warningmsgwindow , Go_on , Stop ) . then ( result => {
3939 if ( result === Go_on ) {
40- this . afterlink ( conf , viaplayer , isrun )
40+ this . afterlink ( conf , viaplayer , isrun ) ;
4141 }
4242 } ) ;
43- break
43+ break ;
4444 case 2 :
45- this . afterlink ( conf , viaplayer , isrun )
46- break
45+ this . afterlink ( conf , viaplayer , isrun ) ;
46+ break ;
4747 }
48- Config . writefile ( Uri . joinPath ( conf . toolsUri , './work/T.TXT' ) , stdout )
49- } )
48+ Config . writefile ( Uri . joinPath ( conf . toolsUri , './work/T.TXT' ) , stdout ) ;
49+ } ) ;
5050 }
5151 private outTerminal ( run : boolean , conf : Config ) {
52- let myenv = process . env
53- let myenvPATH = myenv . PATH + ';' + conf . path + '\\player;' + conf . path + '\\tasm;' + conf . path + '\\masm;'
52+ let myenv = process . env ;
53+ let myenvPATH = myenv . PATH + ';' + conf . path + '\\player;' + conf . path + '\\tasm;' + conf . path + '\\masm;' ;
5454 if ( this . _terminal ?. exitStatus || this . _terminal === null ) {
5555 this . _terminal = window . createTerminal ( {
5656 cwd : conf . workpath ,
@@ -61,36 +61,36 @@ export class MSDOSplayer {
6161 hideFromUser : false ,
6262 } ) ;
6363 }
64- this . _terminal . show ( )
64+ this . _terminal . show ( ) ;
6565 if ( run ) {
66- this . _terminal . sendText ( 'msdos T.EXE' )
66+ this . _terminal . sendText ( 'msdos T.EXE' ) ;
6767 }
6868 else {
69- this . _terminal . sendText ( 'msdos -v5.0 debug T.EXE' )
69+ this . _terminal . sendText ( 'msdos -v5.0 debug T.EXE' ) ;
7070 }
7171 }
7272 public deactivate ( ) {
73- if ( this . _terminal ) this . _terminal . dispose ( )
73+ if ( this . _terminal ) { this . _terminal . dispose ( ) ; }
7474 }
7575
7676 private afterlink ( conf : Config , viaplayer : boolean , runordebug : boolean ) {
77- let debug : string
78- if ( conf . MASMorTASM == 'TASM' ) {
79- debug = 'if exist c:\\tasm\\TDC2.TD copy c:\\tasm\\TDC2.TD TDCONFIG.TD \nTD T.EXE'
77+ let debug : string ;
78+ if ( conf . MASMorTASM === 'TASM' ) {
79+ debug = 'if exist c:\\tasm\\TDC2.TD copy c:\\tasm\\TDC2.TD TDCONFIG.TD \nTD T.EXE' ;
8080 }
8181 else {
82- debug = 'DEBUG T.EXE'
82+ debug = 'DEBUG T.EXE' ;
8383 }
8484 if ( viaplayer ) {
85- this . outTerminal ( runordebug , conf )
85+ this . outTerminal ( runordebug , conf ) ;
8686 }
8787 else {
88- let box = new DOSBox ( )
88+ let box = new DOSBox ( ) ;
8989 if ( runordebug ) {
90- box . openDOSBox ( conf , 'T.EXE\n' + conf . boxruncmd )
90+ box . openDOSBox ( conf , 'T.EXE\n' + conf . boxruncmd ) ;
9191 }
9292 else {
93- box . openDOSBox ( conf , debug )
93+ box . openDOSBox ( conf , debug ) ;
9494 }
9595 }
9696 }
0 commit comments