Commits

Anonymous committed 0873f3e

Added missing file

  • Participants
  • Parent commits 0a2469c

Comments (0)

Files changed (1)

 diff -r 37ecb109fa41 Lib/llvmre.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/Lib/llvmre.py	Mon May 24 22:56:41 2010 +0200
++++ b/Lib/llvmre.py	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,30 @@
 +import sys
 +
 +    return RegexObject(pattern, flags)
 diff -r 37ecb109fa41 Modules/Setup.dist
 --- a/Modules/Setup.dist	Mon May 03 18:00:25 2010 +0200
-+++ b/Modules/Setup.dist	Mon May 24 22:56:41 2010 +0200
++++ b/Modules/Setup.dist	Tue May 25 22:46:17 2010 +0200
 @@ -117,6 +117,8 @@
  pwd pwdmodule.c			# this is needed to find out the user's home dir
  				# if $HOME is not set
  # The zipimport module is always imported at startup. Having it as a
 diff -r 37ecb109fa41 Modules/_llvmre/llvmre.cc
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/Modules/_llvmre/llvmre.cc	Mon May 24 22:56:41 2010 +0200
++++ b/Modules/_llvmre/llvmre.cc	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,1048 @@
 +#include "Python.h"
 +
 +
 diff -r 37ecb109fa41 Modules/_llvmre/llvmre.h
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/Modules/_llvmre/llvmre.h	Mon May 24 22:56:41 2010 +0200
++++ b/Modules/_llvmre/llvmre.h	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,145 @@
 +// -*- C++ -*-
 +#ifndef MODULES_LLVMRE_H
 +};
 +
 +#endif /* MODULES_LLVMRE_H */
+diff -r 37ecb109fa41 Modules/_llvmre/re_opcodes.cc
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/Modules/_llvmre/re_opcodes.cc	Tue May 25 22:46:17 2010 +0200
+@@ -0,0 +1,153 @@
++#include "Python.h"
++
++#include "JIT/global_llvm_data.h"
++#include "JIT/PyTypeBuilder.h"
++
++#include "llvm/BasicBlock.h"
++#include "llvm/Function.h"
++
++#include "llvmre.h"
++
++
++using llvm::BasicBlock;
++using llvm::ConstantInt;
++using llvm::Function;
++using llvm::Type;
++using llvm::Value;
++
++// helper to produce better error messages
++#define _PyErr_SetString(T,S) \
++  PyErr_Format(T, S " (in %s at %s:%d)", \
++               __PRETTY_FUNCTION__ , __FILE__, __LINE__)
++
++RegExOpcodeIn::RegExOpcodeIn(RegExBuilder *builder)
++    : func_(builder->function()),
++      builder_(builder),
++      regex_(func_->regex()),
++      llvm_data_(PyGlobalLlvmData::Get()),
++      context_(this->llvm_data_->context()),
++      negate_(false),
++      literals_(NULL)
++{
++}
++
++bool
++RegExOpcodeIn::EmitIn(PyObject *seq)
++{
++    if (!PySequence_Check(seq)) {
++        _PyErr_SetString(PyExc_TypeError, "Expected a sequence");
++        return false;
++    }
++
++    this->func_->CheckEnd();
++    this->character_ = this->func_->LoadCharacter();
++
++    Py_ssize_t seq_length = PySequence_Size(seq);
++    for (Py_ssize_t index = 0; index < seq_length; ++index) {
++        PyObject *item = PySequence_GetItem(seq, index);
++
++        // make sure that that item is a sequence
++        if (!PySequence_Check(item)) {
++            _PyErr_SetString(PyExc_TypeError, "Expected a sequence");
++            Py_XDECREF(item);
++            return false;
++        }
++        // whose length is two
++        if (PySequence_Size(item) != 2) {
++            _PyErr_SetString(PyExc_ValueError, "Expected a 2-sequence");
++            Py_XDECREF(item);
++            return false;
++        }
++        // the first item is a string
++        PyObject *op = PySequence_GetItem(item, 0);
++        if (!PyString_Check(op)) {
++            _PyErr_SetString(PyExc_TypeError, "Expected a string");
++            Py_XDECREF(op);
++            Py_XDECREF(item);
++            return false;
++        }
++
++        const char *op_str = PyString_AsString(op);
++
++        PyObject *arg = PySequence_GetItem(item, 1);
++
++        Py_XDECREF(item);
++
++        bool result = true;
++
++        if (strcmp(op_str, "literal") == 0) {
++            if (!this->EmitLiteral(arg)) {
++                result = false;
++            }
++        }
++        else if (strcmp(op_str, "negate") == 0) {
++            this->negate_ = true;
++        }
++        else {
++            PyErr_Format(PyExc_ValueError,
++                         "Unsupported opcode '%s' in set", op_str);
++            result = false;
++        }
++
++        Py_XDECREF(op);
++        Py_XDECREF(arg);
++
++        if (!result) {
++            return false;
++        }
++    }
++
++    this->Finish();
++
++    this->func_->Advance();
++    return true;
++}
++
++void
++RegExOpcodeIn::Finish()
++{
++    RegExFunction::BuilderT &irbuilder = this->func_->builder();
++    if (this->literals_ != NULL) {
++        irbuilder.CreateBr(this->literals_block_);
++        if (this->negate_) {
++            irbuilder.SetInsertPoint(this->literals_match_block_);
++            irbuilder.CreateBr(this->func_->fail_block());
++            irbuilder.SetInsertPoint(this->literals_diff_block_);
++        }
++        else {
++            irbuilder.SetInsertPoint(this->literals_diff_block_);
++            irbuilder.CreateBr(this->func_->fail_block());
++            irbuilder.SetInsertPoint(this->literals_match_block_);
++        }
++    }
++}
++
++bool
++RegExOpcodeIn::EmitLiteral(PyObject *arg)
++{
++    RegExFunction::BuilderT &irbuilder = this->func_->builder();
++    if (this->literals_ == NULL) {
++        llvm::BasicBlock *prev = irbuilder.GetInsertBlock();
++        this->literals_block_ = this->func_->CreateBasicBlock("in_literals");
++        this->literals_match_block_ =
++            this->func_->CreateBasicBlock("match_literals");
++        this->literals_diff_block_ =
++            this->func_->CreateBasicBlock("diff_literals");
++        irbuilder.SetInsertPoint(this->literals_block_);
++
++        this->literals_ =
++            irbuilder.CreateSwitch(this->character_,
++                                   this->literals_diff_block_);
++
++        irbuilder.SetInsertPoint(prev);
++    }
++
++    long arg_value = PyInt_AsLong(arg);
++    llvm::ConstantInt *literal = 
++        ConstantInt::get(PyTypeBuilder<Py_UNICODE>::get(this->context_), 
++                         arg_value);
++
++    this->literals_->addCase(literal, this->literals_match_block_);
++
++    return true;
++}
 diff -r 37ecb109fa41 configure
 --- a/configure	Mon May 03 18:00:25 2010 +0200
-+++ b/configure	Mon May 24 22:56:41 2010 +0200
++++ b/configure	Tue May 25 22:46:17 2010 +0200
 @@ -1,63 +1,86 @@
  #! /bin/sh
  # From configure.in Revision: 75132 .
    See PEP 11 for the gory details.
 diff -r 37ecb109fa41 configure.in
 --- a/configure.in	Mon May 03 18:00:25 2010 +0200
-+++ b/configure.in	Mon May 24 22:56:41 2010 +0200
++++ b/configure.in	Tue May 25 22:46:17 2010 +0200
 @@ -509,9 +509,9 @@
  
      LLVM_INC_DIR=`$LLVM_CONFIG --includedir`
          [], [AC_MSG_ERROR([Did not find clang in $LLVM_BIN_DIR])])
 diff -r 37ecb109fa41 proto.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/proto.py	Mon May 24 22:56:41 2010 +0200
++++ b/proto.py	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,132 @@
 +from sre_parse import parse
 +
 +    _main()
 diff -r 37ecb109fa41 pyconfig.h.in
 --- a/pyconfig.h.in	Mon May 03 18:00:25 2010 +0200
-+++ b/pyconfig.h.in	Mon May 24 22:56:41 2010 +0200
++++ b/pyconfig.h.in	Tue May 25 22:46:17 2010 +0200
 @@ -5,6 +5,9 @@
  #define Py_PYCONFIG_H
  
  
 diff -r 37ecb109fa41 recompile.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/recompile.py	Mon May 24 22:56:41 2010 +0200
++++ b/recompile.py	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,51 @@
 +import pickle
 +import llvmre
 +def eval_flags():
 +    import re
 +    print "I", re.I, "L", re.L, "M", re.M, "S", re.S, "U", re.U, "X", re.X
-+    return re.I | re.L | re.M | re.S | re.U | re.X
++    return re.I | re.L | re.M | re.S | re.X, re.U
 +
 +def _main():
 +    with open("regexes.pickle", "r") as infile:
 +        regexes = pickle.load(infile)
 +
-+    unsupported_flags = eval_flags()
++    unsupported_flags, must_flags = eval_flags()
 +
 +    compiled = 0
 +    failed = 0
 +        try:
 +            if not isinstance(re[0], basestring):
 +                continue
-+#            print re
-+#            print parse(re[0])
 +            if re[1] & unsupported_flags > 0:
 +                raise ValueError("Unsupported Flags %d" % re[1])
++            if re[1] & must_flags == 0:
++                raise ValueError("Must Flags not set %d" % re[1])
 +            llvmre.compile(*re)
 +            compiled += 1
 +        except ValueError, e:
 +    _main()
 diff -r 37ecb109fa41 regex.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/regex.py	Mon May 24 22:56:41 2010 +0200
++++ b/regex.py	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,21 @@
 +import llvmre
 +from sre_parse import parse
 +
 diff -r 37ecb109fa41 regexes.pickle
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/regexes.pickle	Mon May 24 22:56:41 2010 +0200
++++ b/regexes.pickle	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,1112 @@
 +(lp0
 +(S'\\bnpgvingr\\b'
 \ No newline at end of file
 diff -r 37ecb109fa41 tests.py
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/tests.py	Mon May 24 22:56:41 2010 +0200
++++ b/tests.py	Tue May 25 22:46:17 2010 +0200
 @@ -0,0 +1,78 @@
 +import unittest
 +