void ECodesAssembler :: readMessage(TokenInfo& token, int& verbId, IdentifierString& subject, int& paramCount) { verbId = mapVerb(token.value); if (verbId == 0) { if (token.check("dispatch")) { verbId = DISPATCH_MESSAGE_ID; } else verbId = EVAL_MESSAGE_ID; } token.read(); while (token.value[0] == '&') { subject.append(token.value); token.read(); subject.append(token.value); token.read(); if (token.value[0] == '$') { subject.append(token.value); token.read(); } } if (token.value[0] == '[') { paramCount = token.readInteger(constants); } else token.raiseErr("Invalid operand (%d)"); token.read("]", "Invalid operand (%d)"); }
void ECodesAssembler :: compileNNCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer) { int n1 = token.readInteger(constants); int n2 = token.readInteger(constants); writeCommand(ByteCommand(code, n1, n2), writer); }
void ECodesAssembler :: compileCreateCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary) { ref_t reference = compileRArg(token, binary); int n = token.readInteger(constants); writeCommand(ByteCommand(code, reference, n), writer); }
void ECodesAssembler :: compileMCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary) { ident_t word = token.read(); if (token.terminal.state == dfaInteger || constants.exist(word)) { int m = 0; if(token.getInteger(m, constants)) { writeCommand(ByteCommand(code, m), writer); } else token.raiseErr("Invalid number (%d)\n"); } else if (word.compare("subject")) { token.read(":", "Invalid operand (%d)"); token.read(); int paramCount = 0; // NOTE: paramCount might be not equal to stackCount (the actual stack size) in the case if variables are used for virtual methods int stackCount = 0; int verbId = mapVerb(token.value); if (verbId == 0) { verbId = EVAL_MESSAGE_ID; } IdentifierString subject; token.read(); bool first = true; while(token.value[0] == '&') { if (first) { first = false; } else subject.append(token.value); token.read(); subject.append(token.value); token.read(); } if (token.value[0] == '[') { paramCount = token.readInteger(constants); } else token.raiseErr("Invalid operand (%d)"); token.read("]", "Invalid operand (%d)"); ref_t subj = binary->mapSubject(subject, false); writeCommand(ByteCommand(code, encodeMessage(subj, verbId, paramCount)), writer); } else throw AssemblerException("Invalid operand (%d)\n", token.terminal.row); }
void ECodesAssembler :: compileMccJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info) { writer.writeByte(code); int label = 0; token.read(); if (info.labels.exist(token.value)) { label = info.labels.get(token.value) - writer.Position() - 8; } else { info.fwdJumps.add(token.value, 4 + writer.Position()); } int message = token.readInteger(constants); writer.writeDWord(message); writer.writeDWord(label); }