db_expr.c (283088) | db_expr.c (283248) |
---|---|
1/*- 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 15 unchanged lines hidden (view full) --- 24 * rights to redistribute these changes. 25 */ 26/* 27 * Author: David B. Golub, Carnegie Mellon University 28 * Date: 7/90 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 15 unchanged lines hidden (view full) --- 24 * rights to redistribute these changes. 25 */ 26/* 27 * Author: David B. Golub, Carnegie Mellon University 28 * Date: 7/90 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/ddb/db_expr.c 283088 2015-05-18 22:27:46Z pfg $"); | 32__FBSDID("$FreeBSD: head/sys/ddb/db_expr.c 283248 2015-05-21 15:16:18Z pfg $"); |
33 34#include <sys/param.h> 35 36#include <ddb/ddb.h> 37#include <ddb/db_lex.h> 38#include <ddb/db_access.h> 39#include <ddb/db_command.h> 40 | 33 34#include <sys/param.h> 35 36#include <ddb/ddb.h> 37#include <ddb/db_lex.h> 38#include <ddb/db_access.h> 39#include <ddb/db_command.h> 40 |
41static boolean_t db_add_expr(db_expr_t *valuep); 42static boolean_t db_mult_expr(db_expr_t *valuep); 43static boolean_t db_shift_expr(db_expr_t *valuep); 44static boolean_t db_term(db_expr_t *valuep); 45static boolean_t db_unary(db_expr_t *valuep); | 41static bool db_add_expr(db_expr_t *valuep); 42static bool db_mult_expr(db_expr_t *valuep); 43static bool db_shift_expr(db_expr_t *valuep); 44static bool db_term(db_expr_t *valuep); 45static bool db_unary(db_expr_t *valuep); |
46 | 46 |
47static boolean_t | 47static bool |
48db_term(db_expr_t *valuep) 49{ 50 int t; 51 52 t = db_read_token(); 53 if (t == tIDENT) { 54 if (!db_value_of_name(db_tok_string, valuep) && 55 !db_value_of_name_pcpu(db_tok_string, valuep) && --- 39 unchanged lines hidden (view full) --- 95 /*NOTREACHED*/ 96 } 97 return (true); 98 } 99 db_unread_token(t); 100 return (false); 101} 102 | 48db_term(db_expr_t *valuep) 49{ 50 int t; 51 52 t = db_read_token(); 53 if (t == tIDENT) { 54 if (!db_value_of_name(db_tok_string, valuep) && 55 !db_value_of_name_pcpu(db_tok_string, valuep) && --- 39 unchanged lines hidden (view full) --- 95 /*NOTREACHED*/ 96 } 97 return (true); 98 } 99 db_unread_token(t); 100 return (false); 101} 102 |
103static boolean_t | 103static bool |
104db_unary(db_expr_t *valuep) 105{ 106 int t; 107 108 t = db_read_token(); 109 if (t == tMINUS) { 110 if (!db_unary(valuep)) { 111 db_error("Syntax error\n"); --- 10 unchanged lines hidden (view full) --- 122 } 123 *valuep = db_get_value((db_addr_t)*valuep, sizeof(void *), false); 124 return (true); 125 } 126 db_unread_token(t); 127 return (db_term(valuep)); 128} 129 | 104db_unary(db_expr_t *valuep) 105{ 106 int t; 107 108 t = db_read_token(); 109 if (t == tMINUS) { 110 if (!db_unary(valuep)) { 111 db_error("Syntax error\n"); --- 10 unchanged lines hidden (view full) --- 122 } 123 *valuep = db_get_value((db_addr_t)*valuep, sizeof(void *), false); 124 return (true); 125 } 126 db_unread_token(t); 127 return (db_term(valuep)); 128} 129 |
130static boolean_t | 130static bool |
131db_mult_expr(db_expr_t *valuep) 132{ 133 db_expr_t lhs, rhs; 134 int t; 135 136 if (!db_unary(&lhs)) 137 return (false); 138 --- 19 unchanged lines hidden (view full) --- 158 } 159 t = db_read_token(); 160 } 161 db_unread_token(t); 162 *valuep = lhs; 163 return (true); 164} 165 | 131db_mult_expr(db_expr_t *valuep) 132{ 133 db_expr_t lhs, rhs; 134 int t; 135 136 if (!db_unary(&lhs)) 137 return (false); 138 --- 19 unchanged lines hidden (view full) --- 158 } 159 t = db_read_token(); 160 } 161 db_unread_token(t); 162 *valuep = lhs; 163 return (true); 164} 165 |
166static boolean_t | 166static bool |
167db_add_expr(db_expr_t *valuep) 168{ 169 db_expr_t lhs, rhs; 170 int t; 171 172 if (!db_mult_expr(&lhs)) 173 return (false); 174 --- 9 unchanged lines hidden (view full) --- 184 lhs -= rhs; 185 t = db_read_token(); 186 } 187 db_unread_token(t); 188 *valuep = lhs; 189 return (true); 190} 191 | 167db_add_expr(db_expr_t *valuep) 168{ 169 db_expr_t lhs, rhs; 170 int t; 171 172 if (!db_mult_expr(&lhs)) 173 return (false); 174 --- 9 unchanged lines hidden (view full) --- 184 lhs -= rhs; 185 t = db_read_token(); 186 } 187 db_unread_token(t); 188 *valuep = lhs; 189 return (true); 190} 191 |
192static boolean_t | 192static bool |
193db_shift_expr(db_expr_t *valuep) 194{ 195 db_expr_t lhs, rhs; 196 int t; 197 198 if (!db_add_expr(&lhs)) 199 return (false); 200 --- 28 unchanged lines hidden --- | 193db_shift_expr(db_expr_t *valuep) 194{ 195 db_expr_t lhs, rhs; 196 int t; 197 198 if (!db_add_expr(&lhs)) 199 return (false); 200 --- 28 unchanged lines hidden --- |