Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ianatha committed Mar 16, 2024
1 parent ae45fe4 commit 949f252
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ stmt
| functionendstmt
| importstmt
| killstmt
| namestmt
| libtagstmt
| dimstmt
| reallocstmt
Expand Down Expand Up @@ -373,6 +374,10 @@ importstmt
: IMPORT filename=string
;

namestmt
: NAME oldfilename=expr AS newfilename=expr
;

killstmt
: KILL filespec=expr
;
Expand Down Expand Up @@ -748,6 +753,10 @@ FUNCTION
: F U N C T I O N
;

NAME
: N A M E
;

KILL
: K I L L
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class IR(@JvmField val symbolTable: SymbolTable) {
MOUSEBUTTONPRESSED("mousebuttonpressed"), MOUSEBUTTONRELEASED("mousebuttonreleased"), ISKEYPRESSED(
"iskeypressed"
),
LTRIMDLR("ltrim$"), RTRIMDLR("rtrim$"), DATEDLR("date$"), TIMEDLR("date$"), KILL("kill")
LTRIMDLR("ltrim$"), RTRIMDLR("rtrim$"), DATEDLR("date$"), TIMEDLR("date$"), KILL("kill"), NAME("name")
}

class InputRef(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4938,6 +4938,18 @@ class IRListener(
)
}

override fun exitNamestmt(ctx: BabaBASICParser.NamestmtContext) {
val oldfilenameExpr = lookupInstruction(ctx.expr())
Types.assertString(ir.symbolTable[filespecExpr.result]!!.type!!.atomTypeId) { getCtxString(ctx) }
val newfilenameExpr = lookupInstruction(ctx.expr())
Types.assertString(ir.symbolTable[filespecExpr.result]!!.type!!.atomTypeId) { getCtxString(ctx) }
// TODO
ir.addInstruction(
sourceFile, currentLineNumber, ctx.start.startIndex, ctx.stop.stopIndex,
OpCode.NAME, SymbolTable.NULL_ID, oldfilenameExpr.result, newfilenameExpr.result
)
}

override fun exitKillstmt(ctx: BabaBASICParser.KillstmtContext) {
val filespecExpr = lookupInstruction(ctx.expr())
Types.assertString(ir.symbolTable[filespecExpr.result]!!.type!!.atomTypeId) { getCtxString(ctx) }
Expand Down

0 comments on commit 949f252

Please sign in to comment.