mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 06:12:27 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
44
third_party/python/Python/wordcode_helpers.h
vendored
Normal file
44
third_party/python/Python/wordcode_helpers.h
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* This file contains code shared by the compiler and the peephole
|
||||
optimizer.
|
||||
*/
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((opcode) << 8) | (oparg)))
|
||||
#else
|
||||
# define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((oparg) << 8) | (opcode)))
|
||||
#endif
|
||||
|
||||
/* Minimum number of code units necessary to encode instruction with
|
||||
EXTENDED_ARGs */
|
||||
static int
|
||||
instrsize(unsigned int oparg)
|
||||
{
|
||||
return oparg <= 0xff ? 1 :
|
||||
oparg <= 0xffff ? 2 :
|
||||
oparg <= 0xffffff ? 3 :
|
||||
4;
|
||||
}
|
||||
|
||||
/* Spits out op/oparg pair using ilen bytes. codestr should be pointed at the
|
||||
desired location of the first EXTENDED_ARG */
|
||||
static void
|
||||
write_op_arg(_Py_CODEUNIT *codestr, unsigned char opcode,
|
||||
unsigned int oparg, int ilen)
|
||||
{
|
||||
switch (ilen) {
|
||||
case 4:
|
||||
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff);
|
||||
/* fall through */
|
||||
case 3:
|
||||
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff);
|
||||
/* fall through */
|
||||
case 2:
|
||||
*codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff);
|
||||
/* fall through */
|
||||
case 1:
|
||||
*codestr++ = PACKOPARG(opcode, oparg & 0xff);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue