Example #1
0
/** <!--******************************************************************-->
 *
 * @fn CHKMvar
 *
 * @brief Touched the node and its sons/attributes
 *
 * @param arg_node Var node to process
 * @param arg_info pointer to info structure
 *
 * @return processed node
 *
 ***************************************************************************/
node *
CHKMvar (node * arg_node, info * arg_info)
{
  DBUG_ENTER ("CHKMvar");
  NODE_ERROR (arg_node) = CHKMTRAV (NODE_ERROR (arg_node), arg_info);
  VAR_NAME (arg_node) = CHKMattribString (VAR_NAME (arg_node), arg_info);
  VAR_DECL (arg_node) = CHKMattribLink (VAR_DECL (arg_node), arg_info);
  DBUG_RETURN (arg_node);
}
Example #2
0
/** <!--******************************************************************-->
 *
 * @fn COPYvar
 *
 * @brief Copies the node and its sons/attributes
 *
 * @param arg_node Var node to process
 * @param arg_info pointer to info structure
 *
 * @return processed node
 *
 ***************************************************************************/
node *
COPYvar (node * arg_node, info * arg_info)
{
  node *result = TBmakeVar (NULL);
  DBUG_ENTER ("COPYvar");
  LUTinsertIntoLutP (INFO_LUT (arg_info), arg_node, result);
  /* Copy attributes */
  VAR_NAME (result) = STRcpy (VAR_NAME (arg_node));
  VAR_DECL (result) =
    LUTsearchInLutPp (INFO_LUT (arg_info), VAR_DECL (arg_node));
  /* Return value */
  DBUG_RETURN (result);
}
Example #3
0
node *LVARglobaldef( node *arg_node, info *arg_info)
{
    char *var_name;

    DBUG_ENTER("LVARglobaldef");

    var_name = VAR_NAME(GLOBALDEF_ID( arg_node));

    /* set declaration of this global variable */
    VAR_DECL(GLOBALDEF_ID( arg_node) ) = arg_node;

    /* check for duplicated variable declaration */
    if(hashmap_contains(arg_info->global, var_name)) {
        CTIerror(":%d: error: '%s' has already been defined in this context",
                NODE_LINE(arg_node), var_name);

        CTIerror(":%d: error: location of earlier definition",
                NODE_LINE((node *)hashmap_get(arg_info->global, var_name)));
        DBUG_RETURN(arg_node);
    }

    /* add global variabele declaration to hashmap */
    hashmap_add(arg_info->global, var_name, arg_node);

    DBUG_RETURN( arg_node);
}
Example #4
0
//set info_type to var type
	node *CTvar(node *arg_node, info *arg_info){
		DBUG_ENTER("CTvar");

		INFO_TYPE(arg_info) = SYMBOL_TYPE(VAR_DECL(arg_node));

		DBUG_RETURN(arg_node);
	}
Example #5
0
void* ol_ast_node(int type, ...) {
  va_list ap;
  void *return_val = 0;
  va_start(ap, type);
  
#define RETURN(val) {return_val=val; goto done;}  

  /* LINK */
  if(type == OL_AST_LINK) {
    VAR_DECL(ol_link_t, o);
    o->type = va_arg(ap, int);
        
    if(o->type == OL_AST_DEF) {
      o->u.def = va_arg(ap, ol_def_t*);
    }
Example #6
0
node *LVARvar( node *arg_node, info *arg_info)
{
    char *var_name;
    node *var_dec;

    DBUG_ENTER("LVARvar");

    var_name = VAR_NAME(arg_node);

    /* check for local variable declaration */
    var_dec = hashmap_get(arg_info->local, var_name);

    /* check for global variable declaration */
    if(!var_dec)
        var_dec = hashmap_get(arg_info->global, var_name);

    if(var_dec)
        VAR_DECL(arg_node) = var_dec;
    else
        CTIerror(":%d: error: unknown identifier '%s'", NODE_LINE(arg_node), var_name);

    DBUG_RETURN( arg_node);
}