FAM_WO_CFA = defConst("W/O", FAM_WO)
function fileOpener(create::Bool)
+ fam = popPS()
fnameLen = popPS()
fnameAddr = popPS()
- fam = popPS()
fname = getString(fnameAddr, fnameLen)
mode = "w"
end
+ global nextFileID
openFiles[nextFileID] = open(fname, mode)
pushPS(nextFileID)
pushPS(0)
fid = popPS()
close(openFiles[fid])
delete!(openFiles, fid)
+
+ pushPS(0) # Result code 0
return NEXT
end)
end
empty!(openFiles)
+ pushPS(0) # Result code 0
return NEXT
end)
TIB_CFA = defConst("TIB", TIB)
NUMTIB, NUMTIB_CFA = defNewVar("#TIB", 0)
-FIB_CFA = defConst("FIB", TIB)
+FIB_CFA = defConst("FIB", FIB)
NUMFIB, NUMFIB_CFA = defNewVar("#FIB", 0)
TOIN, TOIN_CFA = defNewVar(">IN", 0)
QUIT_CFA = defWord("QUIT",
[LIT_CFA, 0, STATE_CFA, STORE_CFA,
+ LIT_CFA, 0, SOURCE_ID_CFA, STORE_CFA,
LIT_CFA, 0, NUMTIB_CFA, STORE_CFA,
RSP0_CFA, RSPSTORE_CFA,
QUERY_CFA,
DUP_CFA, QUERY_FILE_CFA, # Read line from file
INTERPRET_CFA,
INVERT_CFA, ZBRANCH_CFA, -5,
- DROP_CFA, EXIT_CFA])
+ CLOSE_FILE_CFA, DROP_CFA,
+ FROMR_CFA, SOURCE_ID_CFA, STORE_CFA,
+ EXIT_CFA])
-INCLUDE_CFA = defWord("INCLUDE", [LIT_CFA, 32, WORD_CFA, INCLUDED_CFA]);
+INCLUDE_CFA = defWord("INCLUDE", [LIT_CFA, 32, WORD_CFA, INCLUDED_CFA, EXIT_CFA]);
ABORT_CFA = defWord("ABORT",
- [CLOSE_FILES_CFA, PSP0_CFA, PSPSTORE_CFA, QUIT_CFA])
+ [CLOSE_FILES_CFA, DROP_CFA, PSP0_CFA, PSPSTORE_CFA, QUIT_CFA])
BYE_CFA = defPrimWord("BYE", () -> begin
println("\nBye!")
if initFileName != nothing
print("Including definitions from $initFileName...")
- # TODO
+ putString(initFileName, mem[H])
+ pushPS(mem[H])
+ pushPS(length(initFileName))
+ pushRS(INCLUDED_CFA+1)
initialized = true
else
jmp = mem[EXIT_CFA]
while jmp != 0
try
- #println("Entering prim $(getPrimName(jmp))")
+ #print("Entering prim $(getPrimName(jmp)), PS: ")
+ #printPS()
+
jmp = callPrim(jmp)
catch ex