Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: third_party/yasm/patched-yasm/libyasm/value.c

Issue 11364046: Update Yasm to 1.2.0 (Yasm Part 1/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Value handling 2 * Value handling
3 * 3 *
4 * Copyright (C) 2006-2007 Peter Johnson 4 * Copyright (C) 2006-2007 Peter Johnson
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 #include "util.h" 27 #include "util.h"
28 /*@unused@*/ RCSID("$Id: value.c 2220 2009-07-24 19:01:35Z peter $");
29 28
30 #include "libyasm-stdint.h" 29 #include "libyasm-stdint.h"
31 #include "coretype.h" 30 #include "coretype.h"
32 #include "bitvect.h" 31 #include "bitvect.h"
33 32
34 #include "errwarn.h" 33 #include "errwarn.h"
35 #include "intnum.h" 34 #include "intnum.h"
36 #include "floatnum.h" 35 #include "floatnum.h"
37 #include "expr.h" 36 #include "expr.h"
38 #include "value.h" 37 #include "value.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 445 }
447 446
448 int 447 int
449 yasm_value_finalize_expr(yasm_value *value, yasm_expr *e, 448 yasm_value_finalize_expr(yasm_value *value, yasm_expr *e,
450 yasm_bytecode *precbc, unsigned int size) 449 yasm_bytecode *precbc, unsigned int size)
451 { 450 {
452 if (!e) { 451 if (!e) {
453 yasm_value_initialize(value, NULL, size); 452 yasm_value_initialize(value, NULL, size);
454 return 0; 453 return 0;
455 } 454 }
455 yasm_value_initialize(value, e, size);
456 return yasm_value_finalize(value, precbc);
457 }
456 458
457 yasm_value_initialize(value, 459 int
458 yasm_expr__level_tree(e, 1, 1, 0, 0, NULL, NULL), 460 yasm_value_finalize(yasm_value *value, yasm_bytecode *precbc)
459 size); 461 {
462 if (!value->abs)
463 return 0;
464
465 value->abs = yasm_expr__level_tree(value->abs, 1, 1, 0, 0, NULL, NULL);
460 466
461 /* quit early if there was an issue in simplify() */ 467 /* quit early if there was an issue in simplify() */
462 if (yasm_error_occurred()) 468 if (yasm_error_occurred())
463 return 1; 469 return 1;
464 470
465 /* Strip top-level AND masking to an all-1s mask the same size 471 /* Strip top-level AND masking to an all-1s mask the same size
466 * of the value size. This allows forced avoidance of overflow warnings. 472 * of the value size. This allows forced avoidance of overflow warnings.
467 */ 473 */
468 if (value->abs->op == YASM_EXPR_AND) { 474 if (value->abs->op == YASM_EXPR_AND) {
469 int term; 475 int term;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 /* Simplify 0 in abs to NULL */ 548 /* Simplify 0 in abs to NULL */
543 if (value->abs->op == YASM_EXPR_IDENT 549 if (value->abs->op == YASM_EXPR_IDENT
544 && value->abs->terms[0].type == YASM_EXPR_INT 550 && value->abs->terms[0].type == YASM_EXPR_INT
545 && yasm_intnum_is_zero(value->abs->terms[0].data.intn)) { 551 && yasm_intnum_is_zero(value->abs->terms[0].data.intn)) {
546 yasm_expr_destroy(value->abs); 552 yasm_expr_destroy(value->abs);
547 value->abs = NULL; 553 value->abs = NULL;
548 } 554 }
549 return 0; 555 return 0;
550 } 556 }
551 557
552 int
553 yasm_value_finalize(yasm_value *value, yasm_bytecode *precbc)
554 {
555 unsigned int valsize = value->size;
556 return yasm_value_finalize_expr(value, value->abs, precbc, valsize);
557 }
558
559 yasm_intnum * 558 yasm_intnum *
560 yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist) 559 yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist)
561 { 560 {
562 /*@dependent@*/ /*@null@*/ yasm_intnum *intn = NULL; 561 /*@dependent@*/ /*@null@*/ yasm_intnum *intn = NULL;
563 /*@only@*/ yasm_intnum *outval; 562 /*@only@*/ yasm_intnum *outval;
564 int sym_local; 563 int sym_local;
565 564
566 if (value->abs) { 565 if (value->abs) {
567 /* Handle integer expressions, if non-integer or too complex, return 566 /* Handle integer expressions, if non-integer or too complex, return
568 * NULL. 567 * NULL.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 if (value->ip_rel) 762 if (value->ip_rel)
764 fprintf(f, "%*s(IP-relative)\n", indent_level, ""); 763 fprintf(f, "%*s(IP-relative)\n", indent_level, "");
765 if (value->jump_target) 764 if (value->jump_target)
766 fprintf(f, "%*s(Jump target)\n", indent_level, ""); 765 fprintf(f, "%*s(Jump target)\n", indent_level, "");
767 if (value->section_rel) 766 if (value->section_rel)
768 fprintf(f, "%*s(Section-relative)\n", indent_level, ""); 767 fprintf(f, "%*s(Section-relative)\n", indent_level, "");
769 if (value->no_warn) 768 if (value->no_warn)
770 fprintf(f, "%*s(Overflow warnings disabled)\n", indent_level, ""); 769 fprintf(f, "%*s(Overflow warnings disabled)\n", indent_level, "");
771 } 770 }
772 } 771 }
OLDNEW
« no previous file with comments | « third_party/yasm/patched-yasm/libyasm/value.h ('k') | third_party/yasm/patched-yasm/libyasm/xmalloc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698