Пример #1
0
    // Return the string representation for a given component type id
    std::string const get_component_type_name(boost::int32_t type)
    {
        std::string result;

        if (type == component_invalid)
            result = "component_invalid";
        else if ((type < component_last) && (get_derived_type(type) == 0))
            result = components::detail::names[type];
        else if (get_derived_type(type) < component_last && (get_derived_type(type) != 0))
            result = components::detail::names[get_derived_type(type)];
        else
            result = "component";

        if (type == get_base_type(type) || component_invalid == type)
            result += "[" + boost::lexical_cast<std::string>(type) + "]";
        else {
            result += "[" +
                boost::lexical_cast<std::string>
                  (static_cast<int>(get_derived_type(type))) +
                "(" + boost::lexical_cast<std::string>
                    (static_cast<int>(get_base_type(type))) + ")"
                "]";
        }
        return result;
    }
Пример #2
0
tree
UI_To_gnu (Uint Input, tree type)
{
  /* We might have a TYPE with biased representation and be passed an unbiased
     value that doesn't fit.  We always use an unbiased type to be able to hold
     any such possible value for intermediate computations and then rely on a
     conversion back to TYPE to perform the bias adjustment when need be.  */
  tree comp_type
    = TREE_CODE (type) == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type)
      ? get_base_type (type) : type;
  tree gnu_ret;

  if (Input <= Uint_Direct_Last)
    gnu_ret = build_cst_from_int (comp_type, Input - Uint_Direct_Bias);
  else
    {
      Int Idx = Uints_Ptr[Input].Loc;
      Pos Length = Uints_Ptr[Input].Length;
      Int First = Udigits_Ptr[Idx];
      tree gnu_base;

      gcc_assert (Length > 0);

      /* The computations we perform below always require a type at least as
	 large as an integer not to overflow.  FP types are always fine, but
	 INTEGER or ENUMERAL types we are handed may be too short.  We use a
	 base integer type node for the computations in this case and will
	 convert the final result back to the incoming type later on.  */
      if (!SCALAR_FLOAT_TYPE_P (comp_type) && TYPE_PRECISION (comp_type) < 32)
	comp_type = gnat_type_for_size (32, 0);

      gnu_base = build_cst_from_int (comp_type, Base);

      gnu_ret = build_cst_from_int (comp_type, First);
      if (First < 0)
	for (Idx++, Length--; Length; Idx++, Length--)
	  gnu_ret = fold_build2 (MINUS_EXPR, comp_type,
				 fold_build2 (MULT_EXPR, comp_type,
					      gnu_ret, gnu_base),
				 build_cst_from_int (comp_type,
						     Udigits_Ptr[Idx]));
      else
	for (Idx++, Length--; Length; Idx++, Length--)
	  gnu_ret = fold_build2 (PLUS_EXPR, comp_type,
				 fold_build2 (MULT_EXPR, comp_type,
					      gnu_ret, gnu_base),
				 build_cst_from_int (comp_type,
						     Udigits_Ptr[Idx]));
    }

  gnu_ret = convert (type, gnu_ret);

  /* We don't need any NOP_EXPR or NON_LVALUE_EXPR on GNU_RET.  */
  while ((TREE_CODE (gnu_ret) == NOP_EXPR
	  || TREE_CODE (gnu_ret) == NON_LVALUE_EXPR)
	 && TREE_TYPE (TREE_OPERAND (gnu_ret, 0)) == TREE_TYPE (gnu_ret))
    gnu_ret = TREE_OPERAND (gnu_ret, 0);

  return gnu_ret;
}
Пример #3
0
/* binary_opr_exact()
 * Check for an "exact" match to the specified operand types.
 *
 * If one operand is an unknown literal, assume it should be taken to be
 * the same type as the other operand for this purpose.  Also, consider
 * the possibility that the other operand is a domain type that needs to
 * be reduced to its base type to find an "exact" match.
 */
static oid_t
binary_opr_exact(struct list *opname, oid_t arg1, oid_t arg2)
{
	oid_t result;
	bool was_unknown = false;

	/* Unspecified type for one of the arguments? then use the other */
	if ((arg1 == UNKNOWNOID) && (arg2 != INVALID_OID)) {
		arg1 = arg2;
		was_unknown = true;
	} else if ((arg2 == UNKNOWNOID) && (arg1 != INVALID_OID)) {
		arg2 = arg1;
		was_unknown = true;
	}

	result = opername_to_id(opname, arg1, arg2);
	if (OID_VALID(result))
		return result;

	if (was_unknown) {
		/* arg1 and arg2 are the same here, need only look at arg1 */
		oid_t basetype = get_base_type(arg1);
		if (basetype != arg1) {
			result = opername_to_id(opname, basetype, basetype);
			if (OID_VALID(result))
				return result;
		}
	}

	return INVALID_OID;
}
Пример #4
0
static int get_data_size(struct expression *ptr)
{
	struct symbol *type;
	int ret;

	type = get_type(ptr);
	if (!type || type->type != SYM_PTR)
		return 0;
	type = get_base_type(type);
	if (!type)
		return 0;
	ret = bits_to_bytes(type->bit_size);
	if (ret == -1)
		return 0;
	return ret;
}
Пример #5
0
PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {

	return PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_TYPE_STRING, get_base_type());
}
Пример #6
0
/* Make the defun type insertion.
   TYPE says which insertion this is.
   X_P, if nonzero, says not to start a new insertion. */
static void
defun_internal (int type, int x_p)
{
  int base_type;
  char **defun_args, **scan_args;
  const char *category;
  char *defined_name;
  char *type_name = NULL;
  char *type_name2 = NULL;

  {
    char *line;

    /* The @def.. line is the only place in Texinfo where you are
       allowed to use unquoted braces that don't delimit arguments of
       a command or a macro; in any other place it will trigger an
       error message from the reader loop.  The special handling of
       this case inside `args_from_string' is an extra special hack
       which allows this.  The side effect is that if we try to expand
       the rest of the line below, the recursive reader loop will
       signal an error if there are brace-delimited arguments on that line.

       The best solution to this would be to change the syntax of
       @def.. commands so that it doesn't violate Texinfo's own rules.
       But it's probably too late for this now, as it will break a lot
       of existing manuals.

       Unfortunately, this means that you can't call macros, use @value, etc.
       inside @def.. commands, sigh.  */
    get_rest_of_line (0, &line);

    /* Basic line continuation.  If a line ends with \s*@\s* concatanate
       the next line. */
    {
      char *next_line, *new_line;
      int i;

      line_continuation:
        i = strlen (line) - 1;

        if (line[i] == '@' && line[i-1] != '@')
          {
            get_rest_of_line (0, &next_line);
            new_line = (char *) xmalloc (i + strlen (next_line) + 2);
            strncpy (new_line, line, i);
            new_line[i] = '\0';
            free (line);
            strcat (new_line, " ");
            strcat (new_line, next_line);
            line = xstrdup (new_line);
            free (next_line);
            free (new_line);

            goto line_continuation;
          }
    }

    defun_args = (args_from_string (line));
    free (line);
  }

  scan_args = defun_args;

  /* Get base type and category string.  */
  base_type = get_base_type (type);

  /* xx all these const strings should be determined upon
     documentlanguage argument and NOT via gettext  (kama).  */
  switch (type)
    {
    case defun:
    case deftypefun:
      category = _("Function");
      break;
    case defmac:
      category = _("Macro");
      break;
    case defspec:
      category = _("Special Form");
      break;
    case defvar:
    case deftypevar:
      category = _("Variable");
      break;
    case defopt:
      category = _("User Option");
      break;
    case defivar:
    case deftypeivar:
      category = _("Instance Variable");
      break;
    case defmethod:
    case deftypemethod:
      category = _("Method");
      break;
    default:
      category = next_nonwhite_defun_arg (&scan_args);
      break;
    }

  /* The class name.  */
  if ((base_type == deftypecv)
      || (base_type == deftypefn)
      || (base_type == deftypevr)
      || (base_type == defcv)
      || (base_type == defop)
      || (base_type == deftypeivar)
      || (base_type == deftypemethod)
      || (base_type == deftypeop)
     )
    type_name = next_nonwhite_defun_arg (&scan_args);

  /* The type name for typed languages.  */
  if ((base_type == deftypecv)
      || (base_type == deftypeivar)
      || (base_type == deftypemethod)
      || (base_type == deftypeop)
     )
    type_name2 = next_nonwhite_defun_arg (&scan_args);

  /* The function or whatever that's actually being defined.  */
  defined_name = next_nonwhite_defun_arg (&scan_args);

  /* This hack exists solely for the purposes of formatting the Texinfo
     manual.  I couldn't think of a better way.  The token might be a
     simple @@ followed immediately by more text.  If this is the case,
     then the next defun arg is part of this one, and we should
     concatenate them. */
  if (*scan_args && **scan_args && !whitespace (**scan_args)
       && STREQ (defined_name, "@@"))
    {
      char *tem = xmalloc (3 + strlen (scan_args[0]));

      sprintf (tem, "@@%s", scan_args[0]);

      free (scan_args[0]);
      scan_args[0] = tem;
      scan_args++;
      defined_name = tem;
    }

  /* It's easy to write @defun foo(arg1 arg2), but a following ( is
     misparsed by texinfo.tex and this is next to impossible to fix.
     Warn about it.  */
  if (*scan_args && **scan_args && **scan_args == '(')
    warning ("`%c' follows defined name `%s' instead of whitespace",
             **scan_args, defined_name);

  if (!x_p)
    begin_insertion (type);

  /* Write the definition header line.
     This should start at the normal indentation.  */
  current_indent -= default_indentation_increment;
  start_paragraph ();

  if (!html && !xml)
    switch (base_type)
      {
      case deffn:
      case defvr:
      case deftp:
        execute_string (" --- %s: %s", category, defined_name);
        break;
      case deftypefn:
      case deftypevr:
        execute_string (" --- %s: %s %s", category, type_name, defined_name);
        break;
      case defcv:
        execute_string (" --- %s %s %s: %s", category, _("of"), type_name,
                        defined_name);
        break;
      case deftypecv:
      case deftypeivar:
        execute_string (" --- %s %s %s: %s %s", category, _("of"), type_name,
                        type_name2, defined_name);
        break;
      case defop:
        execute_string (" --- %s %s %s: %s", category, _("on"), type_name,
                        defined_name);
        break;
      case deftypeop:
        execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name,
                        type_name2, defined_name);
        break;
      case deftypemethod:
        execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name,
                        type_name2, defined_name);
        break;
      }
  else if (html)
    {
      /* If this is not a @def...x version, it could only
         be a normal version @def.... So start the table here.  */
      if (!x_p)
        insert_string ("<div class=\"defun\">\n");
      else
        rollback_empty_tag ("blockquote");

      /* xx The single words (on, off) used here, should depend on
         documentlanguage and NOT on gettext  --kama.  */
      switch (base_type)
        {
        case deffn:
        case defvr:
        case deftp:
        case deftypefn:
        case deftypevr:
          execute_string ("--- %s: ", category);
          break;

        case defcv:
        case deftypecv:
        case deftypeivar:
	  execute_string ("--- %s %s %s: ", category, _("of"), type_name);
	  break;

        case defop:
        case deftypemethod:
        case deftypeop:
	  execute_string ("--- %s %s %s: ", category, _("on"), type_name);
	  break;
	} /* switch (base_type)... */

      switch (base_type)
        {
        case deffn:
        case defvr:
        case deftp:
          /* <var> is for the following function arguments.  */
          insert_html_tag (START, "b");
          execute_string ("%s", defined_name);
          insert_html_tag (END, "b");
          insert_html_tag (START, "var");
          break;
        case deftypefn:
        case deftypevr:
          execute_string ("%s ", type_name);
          insert_html_tag (START, "b");
          execute_string ("%s", defined_name);
          insert_html_tag (END, "b");
          insert_html_tag (START, "var");
          break;
        case defcv:
        case defop:
          insert_html_tag (START, "b");
          execute_string ("%s", defined_name);
          insert_html_tag (END, "b");
          insert_html_tag (START, "var");
          break;
        case deftypecv:
        case deftypeivar:
        case deftypemethod:
        case deftypeop:
          execute_string ("%s ", type_name2);
          insert_html_tag (START, "b");
          execute_string ("%s", defined_name);
          insert_html_tag (END, "b");
          insert_html_tag (START, "var");
          break;
        }
    }
  else if (xml)
    xml_begin_def_term (base_type, category, defined_name, type_name,
	type_name2);

  current_indent += default_indentation_increment;

  /* Now process the function arguments, if any.  If these carry onto
     the next line, they should be indented by two increments to
     distinguish them from the body of the definition, which is indented
     by one increment.  */
  current_indent += default_indentation_increment;

  switch (base_type)
    {
    case deffn:
    case defop:
      process_defun_args (scan_args, 1);
      break;

      /* Through Makeinfo 1.67 we processed remaining args only for deftp,
         deftypefn, and deftypemethod.  But the libc manual, for example,
         needs to say:
            @deftypevar {char *} tzname[2]
         And simply allowing the extra text seems far simpler than trying
         to invent yet more defn commands.  In any case, we should either
         output it or give an error, not silently ignore it.  */
    default:
      process_defun_args (scan_args, 0);
      break;
    }

  current_indent -= default_indentation_increment;
  if (!html)
    close_single_paragraph ();

  /* Make an entry in the appropriate index.  (XML and
     Docbook already got their entries, so skip them.)  */
  if (!xml)
    switch (base_type)
      {
      case deffn:
      case deftypefn:
	execute_string ("@findex %s\n", defined_name);
	break;
      case defcv:
      case deftypecv:
      case deftypevr:
      case defvr:
	execute_string ("@vindex %s\n", defined_name);
	break;
      case deftypeivar:
	execute_string ("@vindex %s %s %s\n", defined_name, _("of"),
                        type_name);
	break;
      case defop:
      case deftypeop:
      case deftypemethod:
	execute_string ("@findex %s %s %s\n", defined_name, _("on"),
                        type_name);
	break;
      case deftp:
	execute_string ("@tindex %s\n", defined_name);
	break;
      }

  if (xml)
    xml_end_def_term ();
  else if (html)
    {
      inhibit_paragraph_indentation = 1;
      no_indent = 1;
      insert_html_tag (END, "var");
      insert_string ("<br>\n");
      /* Indent the definition a bit.  */
      add_html_block_elt ("<blockquote>");
      no_indent = 0;
      inhibit_paragraph_indentation = 0;
      paragraph_is_open = 0;
    }

  /* Deallocate the token list. */
  scan_args = defun_args;
  while (1)
    {
      char * arg = (*scan_args++);
      if (arg == NULL)
        break;
      free (arg);
    }
  free (defun_args);
}
Пример #7
0
Type const*
Parser::on_base_type(Token tok)
{
    return get_base_type(tok.symbol());
}