@@ -10,7 +10,7 @@ import { getConfiguredLanguage } from "../Spawn/Language";
10
10
import { getLogger } from "log4js" ;
11
11
import { FileHandle } from "fs/promises" ;
12
12
import { hengSpawn , HengSpawnOption } from "../Spawn" ;
13
- import { MeteredChildProcess , MeterResult } from "../Spawn/Meter" ;
13
+ import { MeterResult } from "../Spawn/Meter" ;
14
14
15
15
const compileCachedJudge = new Map < string , string > ( ) ;
16
16
export const SourceCodeName = "srcCode" ;
@@ -29,23 +29,23 @@ export class ExecutableAgent {
29
29
protected logger = getLogger ( "ExecutableAgent" ) ;
30
30
31
31
constructor (
32
- private readonly execType : ExecType ,
33
- private readonly excutable : Executable
32
+ public readonly execType : ExecType ,
33
+ public readonly executable : Executable
34
34
) {
35
35
this . judgeHash = crypto
36
36
. createHash ( "sha256" )
37
37
. update (
38
38
JSON . stringify ( {
39
39
execType,
40
- excutable,
40
+ excutable : executable ,
41
41
} )
42
42
)
43
43
. digest ( "hex" ) ;
44
44
this . configuredLanguage = getConfiguredLanguage (
45
- this . excutable . environment . language ,
45
+ this . executable . environment . language ,
46
46
{
47
47
execType : this . execType ,
48
- excutable : this . excutable ,
48
+ excutable : this . executable ,
49
49
compileDir : "" ,
50
50
}
51
51
) ;
@@ -105,7 +105,7 @@ export class ExecutableAgent {
105
105
await this . fileAgent . init ( false ) ;
106
106
this . fileAgent . add (
107
107
SourceCodeName ,
108
- this . excutable . source ,
108
+ this . executable . source ,
109
109
this . configuredLanguage . srcFileName
110
110
) ;
111
111
}
@@ -196,16 +196,16 @@ export class ExecutableAgent {
196
196
gid : getConfig ( ) . judger . gid ,
197
197
timeLimit :
198
198
languageRunOption . spawnOption ?. timeLimit ??
199
- this . excutable . limit . compiler . cpuTime ,
199
+ this . executable . limit . compiler . cpuTime ,
200
200
memoryLimit :
201
201
languageRunOption . spawnOption ?. memoryLimit ??
202
- this . excutable . limit . compiler . memory ,
202
+ this . executable . limit . compiler . memory ,
203
203
pidLimit :
204
204
languageRunOption . spawnOption ?. pidLimit ??
205
205
getConfig ( ) . judger . defaultPidLimit ,
206
206
fileLimit :
207
207
languageRunOption . spawnOption ?. fileLimit ??
208
- this . excutable . limit . compiler . output ,
208
+ this . executable . limit . compiler . output ,
209
209
} ;
210
210
211
211
const subProc = hengSpawn ( command , args , spawnOption ) ;
@@ -253,15 +253,12 @@ export class ExecutableAgent {
253
253
* @param cwd
254
254
* @returns
255
255
*/
256
- async exec (
257
- cwd ?: string ,
258
- stdio ?: CompleteStdioOptions ,
259
- args ?: string [ ]
260
- ) : Promise < MeteredChildProcess > {
256
+ async program ( cwd ?: string , stdio ?: CompleteStdioOptions , args ?: string [ ] ) {
261
257
this . checkInit ( ) ;
262
- const languageRunOption = this . configuredLanguage . execOptionGenerator ( ) ;
258
+ const languageRunOption =
259
+ this . configuredLanguage . pragramOptionGenerator ( ) ;
263
260
if ( languageRunOption . skip ) {
264
- throw new Error ( "Can't skip exec " ) ;
261
+ throw new Error ( "Can't skip pragram " ) ;
265
262
}
266
263
if ( ! this . compiled && ! this . compileCached ) {
267
264
throw new Error ( "Please compile first" ) ;
@@ -285,20 +282,19 @@ export class ExecutableAgent {
285
282
gid : getConfig ( ) . judger . gid ,
286
283
timeLimit :
287
284
languageRunOption . spawnOption ?. timeLimit ??
288
- this . excutable . limit . runtime . cpuTime ,
285
+ this . executable . limit . runtime . cpuTime ,
289
286
memoryLimit :
290
287
languageRunOption . spawnOption ?. memoryLimit ??
291
- this . excutable . limit . runtime . memory ,
288
+ this . executable . limit . runtime . memory ,
292
289
pidLimit :
293
290
languageRunOption . spawnOption ?. pidLimit ??
294
291
getConfig ( ) . judger . defaultPidLimit ,
295
292
fileLimit :
296
293
languageRunOption . spawnOption ?. fileLimit ??
297
- this . excutable . limit . runtime . output ,
294
+ this . executable . limit . runtime . output ,
298
295
} ;
299
296
300
- const subProc = hengSpawn ( command , args , spawnOption ) ;
301
- return subProc ;
297
+ return hengSpawn ( command , args , spawnOption ) . result ;
302
298
}
303
299
}
304
300
0 commit comments