Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
int.h
00001 /* 00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 00003 # 00004 # This file is part of the PyMite VM. 00005 # The PyMite VM is free software: you can redistribute it and/or modify 00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. 00007 # 00008 # The PyMite VM is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 00012 # is seen in the file COPYING in this directory. 00013 */ 00014 00015 00016 #ifndef __INT_H__ 00017 #define __INT_H__ 00018 00019 00020 /** 00021 * \file 00022 * \brief Integer Object Type 00023 * 00024 * Integer object type header. 00025 */ 00026 00027 /** 00028 * Integer obj 00029 * 00030 * 32b signed integer 00031 */ 00032 typedef struct PmInt_s 00033 { 00034 /** Object descriptor */ 00035 PmObjDesc_t od; 00036 00037 /** Integer value */ 00038 int32_t val; 00039 } PmInt_t, 00040 *pPmInt_t; 00041 00042 00043 /** 00044 * Creates a duplicate Integer object 00045 * 00046 * Created specifically for the index value in FOR_LOOP. 00047 * 00048 * @param pint Pointer to int obj to duplicate. 00049 * @param r_pint Return by ref, ptr to new int 00050 * @return Return status 00051 */ 00052 PmReturn_t int_dup(pPmObj_t pint, pPmObj_t *r_pint); 00053 00054 /** 00055 * Creates a new Integer object 00056 * 00057 * @param val Value to assign int (signed 32-bit). 00058 * @param r_pint Return by ref, ptr to new int 00059 * @return Return status 00060 */ 00061 PmReturn_t int_new(int32_t val, pPmObj_t *r_pint); 00062 00063 /** 00064 * Implements the UNARY_POSITIVE bcode. 00065 * 00066 * Creates a new int with the same value as the given int. 00067 * 00068 * @param pobj Pointer to integer object 00069 * @param r_pint Return by reference, ptr to int 00070 * @return Return status 00071 */ 00072 PmReturn_t int_positive(pPmObj_t pobj, pPmObj_t *r_pint); 00073 00074 /** 00075 * Implements the UNARY_NEGATIVE bcode. 00076 * 00077 * Creates a new int with a value that is the negative of the given int. 00078 * 00079 * @param pobj Pointer to target object 00080 * @param r_pint Return by ref, ptr to int 00081 * @return Return status 00082 */ 00083 PmReturn_t int_negative(pPmObj_t pobj, pPmObj_t *r_pint); 00084 00085 /** 00086 * Implements the UNARY_INVERT bcode. 00087 * 00088 * Creates a new int with a value that is 00089 * the bitwise inversion of the given int. 00090 * 00091 * @param pobj Pointer to integer to invert 00092 * @param r_pint Return by reference; new integer 00093 * @return Return status 00094 */ 00095 PmReturn_t int_bitInvert(pPmObj_t pobj, pPmObj_t *r_pint); 00096 00097 #ifdef HAVE_PRINT 00098 /** 00099 * Sends out an integer object in decimal notation with MSB first. 00100 * The number is preceded with a "-" when necessary. 00101 * 00102 * @param pObj Ptr to int object 00103 * @return Return status 00104 */ 00105 PmReturn_t int_print(pPmObj_t pint); 00106 00107 /** 00108 * Prints the byte in ascii-coded hexadecimal out the platform output 00109 * 00110 * @param b Byte to print 00111 */ 00112 PmReturn_t int_printHexByte(uint8_t b); 00113 00114 /** 00115 * Prints the integer in ascii-coded hexadecimal out the platform output 00116 * 00117 * @param n Integer to print 00118 */ 00119 PmReturn_t _int_printHex(intptr_t n); 00120 00121 /** 00122 * Prints the Int object in ascii-coded hexadecimal out the platform output 00123 * 00124 * @param pint Pointer to Int object 00125 */ 00126 PmReturn_t int_printHex(pPmObj_t pint); 00127 #endif /* HAVE_PRINT */ 00128 00129 /** 00130 * Returns by reference an integer that is x raised to the power of y. 00131 * 00132 * @param px The integer base 00133 * @param py The integer exponent 00134 * @param r_pn Return by reference; New integer with value of x ** y 00135 * @return Return status 00136 */ 00137 PmReturn_t int_pow(pPmObj_t px, pPmObj_t py, pPmObj_t *r_pn); 00138 00139 #endif /* __INT_H__ */
Generated on Tue Jul 12 2022 17:07:01 by
