Пример #1
0
    ScriptObject* ScriptObject::getSlotObject(uint32_t slot)
    {
        Traits* traits = this->traits();
        const TraitsBindingsp td = traits->getTraitsBindings();
        void* p;
        const SlotStorageType sst = td->calcSlotAddrAndSST(slot, (void*)this, p);

        // based on profiling of Flex apps, it's *much* more common for the slot in this case
        // to have a type (vs "atom"), so check for that first...
        if (sst == SST_scriptobject)
        {
            return *((ScriptObject**)p);
        }
        else if (sst == SST_atom)
        {
            Atom const a = *((const Atom*)p);

            // don't call AvmCore::isObject(); it checks for null, which we don't care about here
            if (atomKind(a) == kObjectType)
                return (ScriptObject*)atomPtr(a);

            // else fall thru and return null
        }

        return NULL;
    }
Пример #2
0
 Stringp ClassClosure::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits()->itraits;
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[class "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
Пример #3
0
    /*static*/ CreateInstanceProc FASTCALL ClassClosure::checkForRestrictedInheritance(VTable* ivtable, CreateInstanceProc p)
    {
        if (ivtable)
        {
            Traits* itraits = ivtable->traits;
            if (p == ArrayClass::createInstanceProc && !itraits->needsHashtable())
            {
                // If we are a sealed subclass of Array, we want to check BugCompatibility
                // to see if instances of this class should behave as "semisealed" instead.
                if (!itraits->core->currentBugCompatibility()->bugzilla654807)
                {
                    return SemiSealedArrayObject::createInstanceProc;
                }
            }

            // Bugzilla 688486: if this is unsubclassed array, let it be simple.
            if (itraits == itraits->core->traits.array_itraits)
            {
                return ArrayClass::createUnsubclassedInstanceProc;
            }

            Traits* base = itraits->base;
            if (base != NULL && base->isRestrictedInheritance && base->pool != itraits->pool)
            {
                return ClassClosure::cantInstantiateCreateInstanceProc;
            }
        }
        return p;
    }
Пример #4
0
 Stringp ScriptObject::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits();
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[object "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
Пример #5
0
 std::string expected(void) const
 {
     return traits.get_shared_string(shared_data, type_name) +
            "(" +
            traits.get_shared_string(shared_data, param_typelist) +
            ")";
 }
Пример #6
0
// After loading an ABC and inserting scripts into the verify queue,
// process the work queues until they are empty.
void BaseExecMgr::verifyEarly(Toplevel* toplevel, AbcEnv* abc_env)
{
    GCList<MethodInfo> verifyQueue2(core->GetGC(), kListInitialCapacity);
    int verified;
    do {
        verified = 0;
        while (!verifyTraitsQueue.isEmpty()) {
            Traits* t = verifyTraitsQueue.removeFirst();
            t->resolveSignatures(toplevel);
            TraitsBindingsp td = t->getTraitsBindings();
            enqFunction(t->init);
            for (int i=0, n=td->methodCount; i < n; i++)
                enqFunction(td->getMethod(i));
        }
        while (!verifyFunctionQueue.isEmpty()) {
            MethodInfo* f = verifyFunctionQueue.removeLast();
            if (!isVerified(f)) {
                if (f->declaringTraits()->init != f && f->declaringScope() == NULL) {
                    verifyQueue2.add(f);
                    continue;
                }
                verified++;
                //console << "pre verify " << f << "\n";
                verifyMethod(f, toplevel, abc_env);
                setVerified(f);
                if (config.verifyonly)
                    f->_invoker = verifyOnlyInvoker;
            }
        }
        while (!verifyQueue2.isEmpty())
            verifyFunctionQueue.add(verifyQueue2.removeLast());
    } while (verified > 0);
}
Пример #7
0
    // case-sensitive Boyer-Moore search
    BidiIter find_(BidiIter begin, BidiIter end, Traits const &traits) const
    {
        typedef typename boost::iterator_difference<BidiIter>::type diff_type;
        diff_type const endpos = std::distance(begin, end);
        diff_type offset = static_cast<diff_type>(this->length_);

        for(diff_type curpos = offset; curpos < endpos; curpos += offset)
        {
            std::advance(begin, offset);

            char_type const *pat_tmp = this->last_;
            BidiIter str_tmp = begin;

            for(; traits.translate(*str_tmp) == *pat_tmp; --pat_tmp, --str_tmp)
            {
                if(pat_tmp == this->begin_)
                {
                    return str_tmp;
                }
            }

            offset = this->offsets_[traits.hash(traits.translate(*begin))];
        }

        return end;
    }
Пример #8
0
 static VTable* _newVT(Toplevel* toplevel, PoolObject* pool, uint16_t sz)
 {
     Traits* t = Traits::newTraits(pool, NULL, sz, 0, 0, TRAITSTYPE_RT);
     t->verifyBindings(toplevel);
     t->resolveSignatures(toplevel);
     return toplevel->core()->newVTable(t, NULL, toplevel);
 }
Пример #9
0
    VTable* VTable::newParameterizedVTable(Traits* param_traits, Stringp fullname)
    {
        Toplevel* toplevel = this->toplevel();
        AvmCore* core = toplevel->core();
        Namespacep traitsNs = this->traits->ns();

        GCRef<builtinClassManifest> builtinClasses = toplevel->builtinClasses();
        GCRef<ObjectVectorClass> vectorobj_cls = builtinClasses->get_Vector_objectClass();
        GCRef<ScopeChain> vectorobj_cscope = vectorobj_cls->vtable->init->scope();
        GCRef<ScopeChain> vectorobj_iscope = vectorobj_cls->ivtable()->init->scope();
        VTable* objVecVTable = vectorobj_cls->vtable;
        AbcEnv* objVecAbcEnv = vectorobj_cscope->abcEnv();
        Toplevel* objVecToplevel = objVecVTable->toplevel();
        VTable* objVecIVTable = objVecVTable->ivtable;

        // these cases should all be filtered out by the caller;
        // we only want to handle Vector<SomeObject> here
        AvmAssert(param_traits != NULL &&
                    param_traits != toplevel->intClass()->vtable->traits->itraits &&
                    param_traits != toplevel->uintClass()->vtable->traits->itraits &&
                    param_traits != toplevel->numberClass()->vtable->traits->itraits);

        PoolObject* traitsPool = this->traits->pool;

        Stringp classname = core->internString(fullname->appendLatin1("$"));
        Traits* ctraits = core->domainMgr()->findTraitsInPoolByNameAndNS(traitsPool, classname, traitsNs);
        Traits* itraits;
        if (!ctraits)
        {
            // important: base the new ctraits on objVecVTable->traits, *not* this->traits;
            // we want the result to be based off ObjectVectorClass, not VectorClass
            // (otherwise sizeofInstance would be too small and we'd be crashy)
            ctraits = objVecVTable->traits->newParameterizedCTraits(classname, traitsNs);
            ctraits->verifyBindings(toplevel);

            itraits = traitsPool->resolveParameterizedType(toplevel, this->ivtable->traits, param_traits);
            ctraits->itraits = itraits;
        }
        else
        {
            itraits = ctraits->itraits;
        }

        AvmAssert(itraits != NULL);

        VTable* class_ivtable = builtinClasses->get_ClassClass()->ivtable();

        VTable* cvtab = core->newVTable(ctraits, class_ivtable, objVecToplevel);
        ScopeChain* cvtab_cscope = vectorobj_cscope->cloneWithNewVTable(core->GetGC(), cvtab, objVecAbcEnv);

        VTable* ivtab = core->newVTable(itraits, objVecIVTable, objVecToplevel);
        ScopeChain* ivtab_iscope = vectorobj_iscope->cloneWithNewVTable(core->GetGC(), ivtab, objVecAbcEnv);
        cvtab->ivtable = ivtab;
        ivtab->init = objVecIVTable->init;

        cvtab->resolveSignatures(cvtab_cscope);
        ivtab->resolveSignatures(ivtab_iscope);

        return cvtab;
    }
Пример #10
0
 bool DomainObject::isDynamic (Atom a)
 {
     Traits *traits = getTraits(a);
     if (traits->itraits != NULL) {
         traits = traits->itraits;
     }
     return traits->needsHashtable();
 }
Пример #11
0
 bool DomainObject::isAssignableAs (ClassClosure *asClass, Atom a)
 {
     Traits *traits = getTraits(a);
     if (traits->itraits != NULL) {
         traits = traits->itraits;
     }
     return traits->containsInterface(asClass->traits()->itraits) != 0;
 }
Пример #12
0
 void set_char(char_type ch, bool icase, Traits const &traits)
 {
     if(this->test_icase_(icase))
     {
         ch = icase ? traits.translate_nocase(ch) : traits.translate(ch);
         this->bset_.set(traits.hash(ch));
     }
 }
void shortest_path_regular_tetrahedron()
{
  typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
  typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
  typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
  typedef Traits::Barycentric_coordinate Barycentric_coordinate;
  typedef Traits::FT FT;
  typedef boost::graph_traits<Polyhedron_3> Graph_traits;
  typedef Graph_traits::vertex_iterator vertex_iterator;
  typedef Graph_traits::face_descriptor face_descriptor;
  typedef Graph_traits::face_iterator face_iterator;
  typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;

  Traits traits;

  Traits::Construct_barycentric_coordinate construct_barycentric_coordinate(traits.construct_barycentric_coordinate_object());

  Polyhedron_3 P;

  CGAL::test::make_regular_tetrahedron(P);

  CGAL::set_halfedgeds_items_id(P);

  Barycentric_coordinate b = construct_barycentric_coordinate(FT(1.0) / FT(3.0), FT(1.0) / FT(3.0), FT(1.0) / FT(3.0));

  face_iterator startFace;
  face_iterator endFace;

  boost::tie(startFace,endFace) = CGAL::faces(P);

  face_descriptor firstFace = *startFace;

  Surface_mesh_shortest_path shortestPaths(P, traits);
  //shortestPaths.m_debugOutput = true;
  shortestPaths.add_source_point(firstFace, b);
  shortestPaths.build_sequence_tree();

  vertex_iterator currentVertex;
  vertex_iterator endVertex;

  Kernel::FT sideLength = Kernel::FT(2.0);
  Kernel::FT halfSideLength = sideLength / Kernel::FT(2.0);
  Kernel::FT triangleHeight = CGAL::sqrt((sideLength*sideLength) - (halfSideLength*halfSideLength));

  for (boost::tie(currentVertex, endVertex) = CGAL::vertices(P); currentVertex != endVertex; ++currentVertex)
  {
    if ((*currentVertex)->point().y()==-1)
    {
      CHECK_CLOSE(shortestPaths.shortest_distance_to_source_points(*currentVertex).first, Kernel::FT((triangleHeight * Kernel::FT(4.0)) / Kernel::FT(3.0)), Kernel::FT(0.000001));
    }
    else
    {
      CHECK_CLOSE(shortestPaths.shortest_distance_to_source_points(*currentVertex).first, Kernel::FT((triangleHeight * Kernel::FT(2.0)) / Kernel::FT(3.0)), Kernel::FT(0.000001));
    }
  }
}
Пример #14
0
 script_fact_ctr_parser(
     const param_type& parent_data,
     const std::string& name,
     const std::string& params,
     std::size_t count
 ): shared_data(parent_data.shared_data())
     , type_name(traits.share_string(shared_data, name))
     , param_typelist(traits.share_string(shared_data, params))
     , param_count(count)
 { }
Пример #15
0
inline typename Traits::char_class_type
lookup_classname(Traits const &traits, char const (&cname)[N], bool icase)
{
    typename Traits::char_type name[N] = {0};
    for(std::size_t j = 0; j < N-1; ++j)
    {
        name[j] = traits.widen(cname[j]);
    }
    return traits.lookup_classname(name, name + N - 1, icase);
}
Пример #16
0
 double match_initializer(iterator& current, iterator end)
 {
     traits.skip_space(current, end);
     if(!traits.match(current, end, "{")) return 0.0;
     double res = match_params(current, end);
     if(res == 0.0) return 0.0;
     traits.skip_space(current, end);
     if(!traits.match(current, end, "}")) return 0.0;
     traits.skip_space(current, end);
     return res;
 }
Пример #17
0
	/**
	 *  @pre !Finished()
	 */
	AttributeList& Add(AttribKind attrib, bool value)
	{
		assert(!Finished());
		typedef typename Traits::template EnumBaseType<
			AttribKind
		>::Type Enum;
		_attribs.push_back(Int(Enum(attrib)));
		_attribs.push_back(
			value?
			_traits.TrueValue():
			_traits.FalseValue()
		);
		return *this;
	}
Пример #18
0
 void init_(Traits const &traits, mpl::true_)
 {
     this->fold_.reserve(this->length_ + 1);
     for(unsigned char offset = this->length_; offset; --offset, ++this->last_)
     {
         this->fold_.push_back(traits.fold_case(*this->last_));
         for(typename string_type::const_iterator beg = this->fold_.back().begin(), end = this->fold_.back().end();
             beg != end; ++beg)
         {
             this->offsets_[traits.hash(*beg)] = offset;
         }
     }
     this->fold_.push_back(traits.fold_case(*this->last_));
 }
Пример #19
0
X_monotone_curve_2 makeVerticalLine( Bound x )
{
    Traits traits;
    Traits::Construct_point_2 constructPoint =
        traits.construct_point_2_object( );
    Traits::Construct_x_monotone_segment_2 constructSegment = 
        traits.construct_x_monotone_segment_2_object( );

    std::vector< X_monotone_curve_2 > curves;
    Point_2 p1 = constructPoint( Algebraic_real_1(x), Algebraic_real_1(Bound( -10000 )) );
    Point_2 p2 = constructPoint( x, Bound( +10000 ) );
    constructSegment( p1, p2, std::back_inserter( curves ) );
    return curves[ 0 ];
}
Пример #20
0
	FinishedAttributeList(const std::vector<Int>& attribs)
	 : _attribs(attribs)
	{
		if(!_attribs.empty() && (_attribs.back() != _traits.ListEnd()))
		{
			_attribs.push_back(_traits.ListEnd());
		}

		assert(
			(_attribs.empty()) || (
				(_attribs.size() % 2 == 1) &&
				(_attribs.back() == _traits.ListEnd())
			)
		);
	}
Пример #21
0
    // case-insensitive Boyer-Moore search with case-folding
    BidiIter find_nocase_fold_(BidiIter begin, BidiIter end, Traits const &traits) const
    {
        typedef typename boost::iterator_difference<BidiIter>::type diff_type;
        diff_type const endpos = std::distance(begin, end);
        diff_type offset = static_cast<diff_type>(this->length_);

        for(diff_type curpos = offset; curpos < endpos; curpos += offset)
        {
            std::advance(begin, offset);

            string_type const *pat_tmp = &this->fold_.back();
            BidiIter str_tmp = begin;

            for(; pat_tmp->end() != std::find(pat_tmp->begin(), pat_tmp->end(), *str_tmp);
                --pat_tmp, --str_tmp)
            {
                if(pat_tmp == &this->fold_.front())
                {
                    return str_tmp;
                }
            }

            offset = this->offsets_[traits.hash(*begin)];
        }

        return end;
    }
Пример #22
0
 void init_(Traits const &traits, mpl::false_)
 {
     for(unsigned char offset = this->length_; offset; --offset, ++this->last_)
     {
         this->offsets_[traits.hash(*this->last_)] = offset;
     }
 }
	void initialize_node(node_type *p, const value_type &v){
		p->value = p->cache = v;
		p->modifier = m_traits.default_modifier();
		p->priority = xorshift128();
		p->size = 1;
		p->children[0] = p->children[1] = nullptr;
	}
Пример #24
0
	Stringp ScopeTypeChain::format(AvmCore* core) const
	{
		Stringp r = core->kEmptyString;
		r = r->appendLatin1("STC:[");
		for (int i = 0; i < fullsize; i++)
		{
			if (i > 0)
				r = r->appendLatin1(",");
			Traits* t = getScopeTraitsAt(i);
			bool b = getScopeIsWithAt(i);
			r = r->append(t->format(core));
			r = r->appendLatin1(b?":1":":0");
		}
		r = r->appendLatin1("]");
		return r;
	}
Пример #25
0
inline sequence<BidiIter> make_any_xpression
(
    regex_constants::syntax_option_type flags
  , Traits const &tr
)
{
    using namespace regex_constants;
    typedef typename iterator_value<BidiIter>::type char_type;
    typedef detail::set_matcher<Traits, mpl::int_<2> > set_matcher;
    typedef literal_matcher<Traits, mpl::false_, mpl::true_> literal_matcher;

    char_type const newline = tr.widen('\n');
    set_matcher s;
    s.set_[0] = newline;
    s.set_[1] = 0;
    s.inverse();

    switch(((int)not_dot_newline | not_dot_null) & flags)
    {
    case not_dot_null:
        return make_dynamic<BidiIter>(literal_matcher(char_type(0), tr));

    case not_dot_newline:
        return make_dynamic<BidiIter>(literal_matcher(newline, tr));

    case (int)not_dot_newline | not_dot_null:
        return make_dynamic<BidiIter>(s);

    default:
        return make_dynamic<BidiIter>(any_matcher());
    }
}
Пример #26
0
	void forward_fill(Iterator it, int row, int first, int last){
		value_type acc = m_traits.default_value();
		m_table[row][first] = acc;
		for(int i = first + 1; i < last; ++i, ++it){
			acc = m_traits(acc, *it);
			m_table[row][i] = acc;
		}
	}
Пример #27
0
 line_start_finder(Traits const &traits)
 {
     char_class_type newline = lookup_classname(traits, "newline");
     for(int j = 0; j < 256; ++j)
     {
         this->bits_[j] = traits.isctype(static_cast<char_type>(static_cast<unsigned char>(j)), newline);
     }
 }
Пример #28
0
	void backward_fill(Iterator it, int row, int first, int last){
		value_type acc = m_traits.default_value();
		--it;
		for(int i = first - 1; i >= last; --i, --it){
			acc = m_traits(*it, acc);
			m_table[row][i] = acc;
		}
	}
Пример #29
0
    void nocase(Traits const &traits)
    {
        this->icase_ = true;

        for(int i = 0; i < Size; ++i)
        {
            this->set_[i] = traits.translate_nocase(this->set_[i]);
        }
    }
Пример #30
0
	/**
	 *  @pre !Finished()
	 */
	AttributeList& DontCare(AttribKind attrib)
	{
		assert(!Finished());
		typedef typename Traits::template EnumBaseType<
			AttribKind
		>::Type Enum;
		_attribs.push_back(Int(Enum(attrib)));
		_attribs.push_back(_traits.DontCare());
		return *this;
	}