Example #1
0
 Y interpolate(const X&x) const {
     if (mElements.size() == 0) return Y();
 
     typename std::vector<element_type>::const_iterator it;
     it = std::lower_bound(mElements.begin(), mElements.end(), element_type(x));
     if (it != mElements.begin()) {
         it--;
     }   
     
     return it->eval(x);
 }
Example #2
0
void* token_parse( void* data ) {
	element* e = malloc( sizeof( element ) );
	e->name = malloc( sizeof( char ) * strlen( (char*)data ) );
	strcpy( e->name, (char*)data );
	e->type = element_type( e->name );
	if ( e->type == kNum) {
		char* end;
		double n = strtod( e->name, &end );
		e->value = (float)n;
	}
	return e;
}
Example #3
0
int ProxyFactory::findConstructor(jccl::ConfigElementPtr element)
{
   std::string element_type(element->getID());

   for(unsigned i=0;i<mConstructors.size();i++)
   {
      if(mConstructors[i]->getElementType() == element_type)
      {
         return i;
      }
   }

   return -1;
}
 void option_target::initialize(const std::string& name, const json* schema, json* result) {
     auto& o = schema->as_object();
     auto f = o.find(option_key::value);
     std::string s = f != o.end() ? f->second : "";
     this->element = element_type(s.back());
     if (this->element == json::content_type::null) {
         if (not name.empty()) {
             result->as_object().emplace(std::make_pair(name, true));
         }
         return;
     }
     this->container = container_type(s.front());
     this->name = name;
     this->result = result;
     this->assign_default(o);
 }
Example #5
0
void TypeArrayKlass::print_value_on(outputStream* st) const {
  assert(is_klass(), "must be klass");
  st->print("{type array ");
  switch (element_type()) {
    case T_BOOLEAN: st->print("bool");    break;
    case T_CHAR:    st->print("char");    break;
    case T_FLOAT:   st->print("float");   break;
    case T_DOUBLE:  st->print("double");  break;
    case T_BYTE:    st->print("byte");    break;
    case T_SHORT:   st->print("short");   break;
    case T_INT:     st->print("int");     break;
    case T_LONG:    st->print("long");    break;
    default: ShouldNotReachHere();
  }
  st->print("}");
}
void TypeArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
    assert(s->is_typeArray(), "must be type array");

    // Check destination
    if (!d->is_typeArray() || element_type() != TypeArrayKlass::cast(d->klass())->element_type()) {
        THROW(vmSymbols::java_lang_ArrayStoreException());
    }

    // Check is all offsets and lengths are non negative
    if (src_pos < 0 || dst_pos < 0 || length < 0) {
        THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
    }
    // Check if the ranges are valid
    if  ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
            || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
        THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
    }
    // Check zero copy
    if (length == 0)
        return;

#ifdef PROFILE_OBJECT_INFO
    if (ProfileObjectInfo) {
        ResourceMark rm;
        if (s->poi()) {
            s->poi()->batch_mark_load(length);
        }
        if (d->poi()) {
            d->poi()->batch_mark_store(length);
        }
    }
#endif
#ifdef PROFILE_OBJECT_ADDRESS_INFO
    if (ProfileObjectAddressInfo) {
        ObjectAddressInfoTable *oait = Universe::object_address_info_table();
        oait->batch_mark_load (s, length);
        oait->batch_mark_store(d, length);
    }
#endif

    // This is an attempt to make the copy_array fast.
    int l2es = log2_element_size();
    int ihs = array_header_in_bytes() / wordSize;
    char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es);
    char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es);
    Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es);
}
Example #7
0
void 
beziervolumeobject::add ( element_type const& v )
{
  _volumes.push_back( element_type(v) );

  element_type& p = _volumes.back();

  while (p.degree_u() <= 1) p.elevate_u();
  while (p.degree_v() <= 1) p.elevate_v();
  while (p.degree_w() <= 1) p.elevate_w();

  for (element_type::attribute_volume_map::iterator d = p.data_begin(); d != p.data_end(); ++d)
  {
    while (d->second.degree_u() <= 1) d->second.elevate_u();
    while (d->second.degree_v() <= 1) d->second.elevate_v();
    while (d->second.degree_w() <= 1) d->second.elevate_w();
  }
}
Example #8
0
        /* Evaluate at multiple locations, assuming xx is sorted ascending */
        std::vector<Y> interpolate(const std::vector<X>& xx) const {
            if (mElements.size() == 0) return std::vector<Y>(xx.size());
        
            typename std::vector<X>::const_iterator it;
            typename std::vector<element_type>::const_iterator it2;
            it2 = mElements.begin();
            std::vector<Y> ys;
            for (it = xx.begin(); it != xx.end(); it++) {
                it2 = std::lower_bound(it2, mElements.end(), element_type(*it));
                if (it2 != mElements.begin()) {
                    it2--;
                }
                
                ys.push_back(it2->eval(*it));
            }

            return ys;
        }
Example #9
0
bool
glsl_type::contains_opaque() const {
   switch (base_type) {
   case GLSL_TYPE_SAMPLER:
   case GLSL_TYPE_IMAGE:
   case GLSL_TYPE_ATOMIC_UINT:
      return true;
   case GLSL_TYPE_ARRAY:
      return element_type()->contains_opaque();
   case GLSL_TYPE_STRUCT:
      for (unsigned int i = 0; i < length; i++) {
         if (fields.structure[i].type->contains_opaque())
            return true;
      }
      return false;
   default:
      return false;
   }
}
void typeArrayKlass::oop_print_on(oop obj, outputStream* st) {
  arrayKlass::oop_print_on(obj, st);
  typeArrayOop ta = typeArrayOop(obj);
  int print_len = MIN2((intx) ta->length(), MaxElementPrintSize);
  switch (element_type()) {
    case T_BOOLEAN: print_boolean_array(ta, print_len, st); break;
    case T_CHAR:    print_char_array(ta, print_len, st);    break;
    case T_FLOAT:   print_float_array(ta, print_len, st);   break;
    case T_DOUBLE:  print_double_array(ta, print_len, st);  break;
    case T_BYTE:    print_byte_array(ta, print_len, st);    break;
    case T_SHORT:   print_short_array(ta, print_len, st);   break;
    case T_INT:     print_int_array(ta, print_len, st);     break;
    case T_LONG:    print_long_array(ta, print_len, st);    break;
    default: ShouldNotReachHere();
  }
  int remaining = ta->length() - print_len;
  if (remaining > 0) {
    tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
  }
}
Example #11
0
 /**
  * Determines if the given type is a specialization (i.e. more specific) of this type.
  * @param other The other type to check for specialization.
  * @return Returns true if the other type is a specialization or false if not.
  */
 bool is_specialization(Type const& other) const
 {
     // For the other type to be a specialization, it must be an Hash or Struct
     // The key types must match
     // The element types must match
     // And the range of other needs to be inside of this type's range
     int64_t from, to;
     auto hash = boost::get<basic_hash<Type>>(&other);
     if (hash) {
         // Check for Hash
         if (hash->key_type() != _key_type || hash->element_type() != _element_type) {
             return false;
         }
         from = hash->from();
         to = hash->to();
     } else {
         // Check for a Struct
         auto structure = boost::get<basic_struct<Type>>(&other);
         if (!structure || !boost::get<string>(&_key_type)) {
             return false;
         }
         // Ensure all elements of the structure are of the element type
         for (auto& kvp : structure->types()) {
             if (kvp.second != _element_type) {
                 return false;
             }
         }
         from = to = structure->types().size();
     }
     // Check for equality
     if (from == _from && to == _to) {
         return false;
     }
     return std::min(from, to) >= std::min(_from, _to) &&
            std::max(from, to) <= std::max(_from, _to);
 }
Example #12
0
// ------------------------------------------------------------------
// ciTypeArrayKlass::ciTypeArrayKlass
ciTypeArrayKlass::ciTypeArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) {
  assert(get_Klass()->oop_is_typeArray(), "wrong type");
  assert(element_type() == get_typeArrayKlass()->element_type(), "");
}
Example #13
0
DataType::ConstPtr DataTypeClassNameParser::parse_one(const std::string& type, const NativeDataTypes& native_types) {
  bool is_frozen = DataTypeClassNameParser::is_frozen(type);

  std::string class_name;

  if (is_reversed(type) || is_frozen) {
    if (!get_nested_class_name(type, &class_name)) {
      return DataType::ConstPtr();
    }
  } else {
    class_name = type;
  }

  Parser parser(class_name, 0);
  std::string next;

  parser.get_next_name(&next);

  if (starts_with(next, LIST_TYPE)) {
    TypeParamsVec params;
    if (!parser.get_type_params(&params) || params.empty()) {
      return DataType::ConstPtr();
    }
    DataType::ConstPtr element_type(parse_one(params[0], native_types));
    if (!element_type) {
      return DataType::ConstPtr();
    }
    return CollectionType::list(element_type, is_frozen);
  } else if(starts_with(next, SET_TYPE)) {
    TypeParamsVec params;
    if (!parser.get_type_params(&params) || params.empty()) {
      return DataType::ConstPtr();
    }
    DataType::ConstPtr element_type(parse_one(params[0], native_types));
    if (!element_type) {
      return DataType::ConstPtr();
    }
    return CollectionType::set(element_type, is_frozen);
  } else if(starts_with(next, MAP_TYPE)) {
    TypeParamsVec params;
    if (!parser.get_type_params(&params) || params.size() < 2) {
      return DataType::ConstPtr();
    }
    DataType::ConstPtr key_type(parse_one(params[0], native_types));
    DataType::ConstPtr value_type(parse_one(params[1], native_types));
    if (!key_type || !value_type) {
      return DataType::ConstPtr();
    }
    return CollectionType::map(key_type, value_type, is_frozen);
  }

  if (is_frozen) {
    LOG_WARN("Got a frozen type for something other than a collection, "
             "this driver might be too old for your version of Cassandra");
  }

  if (is_user_type(next)) {
    parser.skip(); // Skip '('

    std::string keyspace;
    if (!parser.read_one(&keyspace)) {
      return DataType::ConstPtr();
    }
    parser.skip_blank_and_comma();

    std::string hex;
    if (!parser.read_one(&hex)) {
      return DataType::ConstPtr();
    }

    std::string type_name;
    if (!from_hex(hex, &type_name)) {
      LOG_ERROR("Invalid hex string \"%s\" for parameter", hex.c_str());
      return DataType::ConstPtr();
    }

    if (keyspace.empty() || type_name.empty()) {
      LOG_ERROR("UDT has no keyspace or type name");
      return DataType::ConstPtr();
    }

    parser.skip_blank_and_comma();
    NameAndTypeParamsVec raw_fields;
    if (!parser.get_name_and_type_params(&raw_fields)) {
      return DataType::ConstPtr();
    }

    UserType::FieldVec fields;
    for (NameAndTypeParamsVec::const_iterator i = raw_fields.begin(),
         end = raw_fields.end(); i != end; ++i) {
      DataType::ConstPtr data_type = parse_one(i->second, native_types);
      if (!data_type) {
        return DataType::ConstPtr();
      }
      fields.push_back(UserType::Field(i->first, data_type));
    }

    return DataType::ConstPtr(new UserType(keyspace, type_name, fields, true));
  }

  if (is_tuple_type(type)) {
    TypeParamsVec raw_types;
    if (!parser.get_type_params(&raw_types)) {
      return DataType::ConstPtr();
    }

    DataType::Vec types;
    for (TypeParamsVec::const_iterator i = raw_types.begin(),
         end = raw_types.end(); i != end; ++i) {
      DataType::ConstPtr data_type = parse_one(*i, native_types);
      if (!data_type) {
        return DataType::ConstPtr();
      }
      types.push_back(data_type);
    }

    return DataType::ConstPtr(new TupleType(types, true));
  }

  DataType::ConstPtr native_type(native_types.by_class_name(next));
  if (native_type) {
    return native_type;
  }

  return DataType::ConstPtr(new CustomType(next));
}
Example #14
0
 void set(const TId id, const TValue value) final {
     m_vector.push_back(element_type(id, value));
 }
Example #15
0
	const Type* type_of_element(size_t idx) const override { return element_type(); }
Example #16
0
 reference dereference() const {
     return element_type(
             vec->queue[part], vec->buf[part],
             pos - vec->part[part]
             );
 }
Example #17
0
namespace PRBF
{

// *****************************************************************************

const element_type element_type::sof = element_type(element_type::local, 2, element_type::MPA);
const element_type element_type::eof = element_type(element_type::local, 1, element_type::MPA);
const element_type element_type::local_CBC = element_type(element_type::local, 0, element_type::CBC);
const element_type element_type::local_MPA = element_type(element_type::local, 0, element_type::MPA);

// *****************************************************************************
element_type::element_type()
{
	set(local, 0, MPA);

	return;
}

// *****************************************************************************
element_type::element_type(tower_type_t tower_type,
		tower_ID_t tower_ID, chip_type_t chip_type)
{
	set(tower_type, tower_ID, chip_type);

	return;
}

// *****************************************************************************
void element_type::set(tower_type_t tower_type, tower_ID_t tower_ID,
        chip_type_t chip_type)
{
	set_tower_type(tower_type);
	set_tower_ID(tower_ID);
	set_chip_type(chip_type);

	return;
}

// *****************************************************************************
void element_type::set_tower_type(tower_type_t tower_type)
{
	this->tower_type = tower_type;

	return;
}

// *****************************************************************************
element_type::tower_type_t element_type::get_tower_type() const
{
	return (tower_type);
}

// *****************************************************************************
void element_type::set_tower_ID(tower_ID_t tower_ID)
{
	this->tower_ID = tower_ID;

	return;
}

// *****************************************************************************
element_type::tower_ID_t element_type::get_tower_ID() const
{
	return (tower_ID);
}

// *****************************************************************************
void element_type::set_chip_type(chip_type_t chip_type)
{
	this->chip_type = chip_type;

	return;
}

// *****************************************************************************
element_type::chip_type_t element_type::get_chip_type() const
{
    return (chip_type);
}

// *****************************************************************************
bool element_type::operator== (const element_type& rhs) const
{
    bool equal = true;

    equal &= (tower_type == rhs.tower_type);
    equal &= (tower_ID == rhs.tower_ID);
    equal &= (chip_type == rhs.chip_type);

    return (equal);
}

// *****************************************************************************
std::string element_type::get_string() const
{
    std::stringstream out_string;

    out_string << "[";

    if (*this == element_type::sof)
    {
        out_string << std::setw(17) << std::left << "SOF";
    }
    else if (*this == element_type::eof)
    {
        out_string << std::setw(17) << std::left << "EOF";
    }
    else
    {
        if (tower_type == local)
        {
            out_string << "tt=L,";
        }
        else
        {
            out_string << "tt=A,";
        }

        out_string << "id=0x" << std::hex << tower_ID << ",";

        if (chip_type == MPA)
        {
            out_string << "c=MPA";
        }
        else
        {
            out_string << "c=CBC";
        }
    }

    out_string << "]";

    return (out_string.str());
}

// *****************************************************************************
std::ostream& operator<< (std::ostream& stream, const element_type& type_field)
{
    stream << type_field.get_string();

    return (stream);
}

// *****************************************************************************
} // namespace PRBF
Example #18
0
/*
 *	move - move from one element to another
 *
 *	entry -
 *	   library - library_t *
 *	   event - robo_event_t *
 */
int
move(
    library_t *library,
    robo_event_t *event)
{
    dev_ent_t 	*un;
    int 		err = -1, retry, timeout;
    char 		*l_mess = library->un->dis_mes[DIS_MES_NORM];
    char 		*MES_9079 =
        catgets(catfd, SET, 9079, "move from %s to %s %s");
    char 		*mess, *src_mess, *des_mess, *i_mess;
    robot_internal_t 	*cmd = &event->request.internal;
    int 		added_more_time = FALSE;
    sam_extended_sense_t *sense = (sam_extended_sense_t *)
                                  SHM_REF_ADDR(library->un->sense);
    int		movmed_err;

    un = library->un;
    src_mess = element_string(element_type(library, cmd->source));
    des_mess = element_string(element_type(library, cmd->destination1));
    if (cmd->flags.b.invert1)
        i_mess = catgets(catfd, SET, 9084, "invert");
    else
        i_mess = "";

    mess = (char *)malloc_wait(strlen(MES_9079) + strlen(src_mess) +
                               strlen(des_mess) + strlen(i_mess) + 10, 4, 0);
    sprintf(mess, MES_9079, src_mess, des_mess, i_mess);
    memccpy(l_mess, mess, '\0', DIS_MES_LEN);
    free(mess);
    DevLog(DL_DETAIL(5057),
           cmd->source, cmd->flags.b.invert1 ? "invert" : "asis",
           cmd->destination1);

    /*
     * A programming note from DocStore states that you should
     * allow up to 4 minutes for a move.  This is to allow
     * for recovery and retry by the robot.	 If other robots need
     * different time outs, this is the place to put um.
     */
    switch (library->un->type) {
    case DT_DLT2700:
        timeout = 300;
        break;

    case DT_DOCSTOR:
        timeout = 4 * 60;
        break;

    case DT_METD28:
    /* FALLTHROUGH */
    case DT_METD360:
    /* FALLTHROUGH */
    case DT_SPECLOG:
    /* FALLTHROUGH */
    case DT_ATL1500:
    /* FALLTHROUGH */
    case DT_ODI_NEO:
    /* FALLTHROUGH */
    case DT_QUANTUMC4:
    /* FALLTHROUGH */
    case DT_STK97XX:
    /* FALLTHROUGH */
    case DT_FJNMXX:
    /* FALLTHROUGH */
    case DT_SL3000:
    /* FALLTHROUGH */
    case DT_SLPYTHON:
        timeout = 10 * 60;
        break;

    default:
        timeout = 5 * 60;
        break;
    }

    mutex_lock(&library->un->io_mutex);
    retry = 2;
    do {
        time_t start;

        TAPEALERT(library->open_fd, library->un);
        memset(sense, 0, sizeof (sam_extended_sense_t));
        start = time(NULL);
        movmed_err = scsi_cmd(library->open_fd, library->un,
                              SCMD_MOVE_MEDIUM, timeout,
                              cmd->transport, cmd->source, cmd->destination1,
                              (cmd->flags.b.invert1 ? 1 : 0));
        TAPEALERT(library->open_fd, library->un);
        if (movmed_err < 0) {
            DevLog(DL_TIME(5177), cmd->source,
                   cmd->flags.b.invert1 ? "invert" : "asis",
                   cmd->destination1, time(NULL) - start);

            GENERIC_SCSI_ERROR_PROCESSING(library->un,
                                          library->scsi_err_tab, 0,
                                          err, added_more_time, retry,
                                          /* code for DOWN_EQU */
            if (!cmd->flags.b.noerror) {
            err = DOWN_EQU;
            if (sense->es_add_code == 0x40 &&
                        sense->es_qual_code == 0x02) {
                    move_drive_error(library, cmd->source,
                                     cmd->destination1, &err);
                } else {
                    down_library(library, SAM_STATE_CHANGE);
                }
                retry = 1;
                /* MACRO for cstyle */
            }
            break;
            /* MACRO for cstyle */,
 ciInstance* component_mirror() {
   // This is a real field in arrayKlass, but we derive it from element_type.
   return element_type()->java_mirror();
 }
Example #20
0
 BasicType     element_basic_type() { return element_type()->basic_type(); }