public void Add(ushort lineNumber, params object[] instrs) { var tokens = Tokenize(instrs); var line = new C64BasicInstruction { Address = Address.Ptr16(lineNumber), Line = tokens, }; lines.Add(lineNumber, line); }
private RtlInstructionCluster GetRtl(C64BasicInstruction line) { this.rtlInstructions = new List <RtlInstruction>(); this.iclass = InstrClass.Linear; this.m = new RtlEmitter(rtlInstructions); Debug.Print("{0}", line); this.line = line.Line; this.i = 0; while (this.i < this.line.Length) { ParseStatement(); } return(m.MakeCluster(line.Address, 1, iclass)); }
private RtlInstructionCluster GetRtl(C64BasicInstruction line) { this.cluster = new RtlInstructionCluster(line.Address, 1); this.cluster.Class = RtlClass.Linear; this.emitter = new RtlEmitter(cluster.Instructions); Debug.Print("{0}", line); this.line = line.Line; this.i = 0; while (this.i < this.line.Length) { ParseStatement(); } return(cluster); }
private RtlInstructionCluster GetRtl(C64BasicInstruction line) { this.rtlInstructions = new List <RtlInstruction>(); this.rtlc = RtlClass.Linear; this.m = new RtlEmitter(rtlInstructions); Debug.Print("{0}", line); this.line = line.Line; this.i = 0; while (this.i < this.line.Length) { ParseStatement(); } return(new RtlInstructionCluster(line.Address, 1, rtlInstructions.ToArray()) { Class = rtlc }); }
private void ParseStatement() { if (!EatSpaces()) { return; } byte b = line[i++]; switch (b) { case (byte)Token.END: var ppp = host.EnsurePseudoProcedure("__End", VoidType.Instance, 0); ppp.Characteristics = new ProcedureCharacteristics { Terminates = true, }; emitter.SideEffect(PseudoProc(ppp, VoidType.Instance)); i = line.Length; // We never return from end. return; case (byte)Token.CLOSE: RewriteClose(); break; case (byte)Token.CLR: RewriteClr(); break; case (byte)Token.FOR: RewriteFor(); break; case (byte)Token.GET: RewriteGet(); break; case (byte)Token.GOSUB: RewriteGosub(); break; case (byte)Token.GOTO: RewriteGoto(); break; case (byte)Token.IF: RewriteIf(); break; case (byte)Token.INPUT: RewriteInput(); break; case (byte)Token.INPUT_hash: RewriteInput_hash(); break; case (byte)Token.NEXT: RewriteNext(); break; case (byte)Token.OPEN: RewriteOpen(); break; case (byte)Token.POKE: RewritePoke(); break; case (byte)Token.PRINT: RewritePrint(); break; case (byte)Token.PRINT_hash: RewritePrint_hash(); break; case (byte)Token.REM: //$TODO: annotation i = line.Length; return; case (byte)Token.RETURN: RewriteReturn(); break; case (byte)Token.SYS: RewriteSys(); break; case (byte)':': // Statement separator. break; default: if (0x41 <= b && b <= 0x5A) { --i; RewriteLet(); break; } throw new NotImplementedException(string.Format( "Unimplemented BASIC token {0:X2} [{1}].", (int)line[i - 1], C64BasicInstruction.TokenToString(b))); } }