Mercurial > hg > index.cgi
comparison lwasm/pass1.c @ 370:8764142b3192
Convert internal error/warning handling framework to a new unified system
Replace the ad hoc error and warning handling with a new system that
codifies the errors with specific codes. This makes it possible in the
future for error numbers to be used for testing and other purposes. It also
makes sure the error strings themselves are consistent.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 22 Jun 2015 18:49:38 -0600 |
parents | c6d2a1f54e0c |
children | 2593fd529be5 |
comparison
equal
deleted
inserted
replaced
369:682524a1f32f | 370:8764142b3192 |
---|---|
320 { | 320 { |
321 // macro expansion failed | 321 // macro expansion failed |
322 if (expand_struct(as, cl, &p1, sym) != 0) | 322 if (expand_struct(as, cl, &p1, sym) != 0) |
323 { | 323 { |
324 // structure expansion failed | 324 // structure expansion failed |
325 lwasm_register_error(as, cl, "Bad opcode"); | 325 lwasm_register_error(as, cl, E_OPCODE_BAD); |
326 } | 326 } |
327 } | 327 } |
328 } | 328 } |
329 } | 329 } |
330 else | 330 else |
332 cl -> insn = opnum; | 332 cl -> insn = opnum; |
333 // no parse func means operand doesn't matter | 333 // no parse func means operand doesn't matter |
334 if (instab[opnum].parse) | 334 if (instab[opnum].parse) |
335 { | 335 { |
336 if (CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6309)) | 336 if (CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6309)) |
337 lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym); | 337 lwasm_register_error2(as, cl, E_6309_INVALID, "(%s)", sym); |
338 if (!CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6809)) | 338 if (!CURPRAGMA(cl, PRAGMA_6809) && (instab[opnum].flags & lwasm_insn_is6809)) |
339 lwasm_register_error(as, cl, "Illegal use of 6809 instruction in 6309 mode (%s)", sym); | 339 lwasm_register_error2(as, cl, E_6809_INVALID, "(%s)", sym); |
340 | 340 |
341 if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct) | 341 if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct) |
342 { | 342 { |
343 cl -> len = -1; | 343 cl -> len = -1; |
344 // call parse function | 344 // call parse function |
358 } | 358 } |
359 | 359 |
360 if (*p1 && !isspace(*p1) && !(cl -> err)) | 360 if (*p1 && !isspace(*p1) && !(cl -> err)) |
361 { | 361 { |
362 // flag bad operand error | 362 // flag bad operand error |
363 lwasm_register_error(as, cl, "Bad operand (%s)", p1); | 363 lwasm_register_error2(as, cl, E_OPERAND_BAD, "(%s)", p1); |
364 } | 364 } |
365 | 365 |
366 /* do a reduction on the line expressions to avoid carrying excessive expression baggage if not needed */ | 366 /* do a reduction on the line expressions to avoid carrying excessive expression baggage if not needed */ |
367 lwasm_reduce_line_exprs(cl); | 367 lwasm_reduce_line_exprs(cl); |
368 } | 368 } |
369 else if (as -> instruct == 1) | 369 else if (as -> instruct == 1) |
370 { | 370 { |
371 lwasm_register_error(as, cl, "Bad operand (%s)", p1); | 371 lwasm_register_error2(as, cl, E_OPERAND_BAD, "(%s)", p1); |
372 } | 372 } |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
385 if (instab[cl -> insn].flags & lwasm_insn_setdata) | 385 if (instab[cl -> insn].flags & lwasm_insn_setdata) |
386 { | 386 { |
387 if (!register_symbol(as, cl, cl -> sym, cl -> daddr, symbol_flag_none)) | 387 if (!register_symbol(as, cl, cl -> sym, cl -> daddr, symbol_flag_none)) |
388 { | 388 { |
389 // symbol error | 389 // symbol error |
390 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym); | 390 // lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", cl -> sym); |
391 } | 391 } |
392 } | 392 } |
393 else | 393 else |
394 { | 394 { |
395 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none)) | 395 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none)) |
396 { | 396 { |
397 // symbol error | 397 // symbol error |
398 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym); | 398 // lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", cl -> sym); |
399 } | 399 } |
400 } | 400 } |
401 } | 401 } |
402 debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr)); | 402 debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr)); |
403 } | 403 } |