#include "attrib.h"

This page has information from files attrib.h and attrib.c.

Contents


Public Routines in File attrib.c

Index

attribute_name_to_idfprint_attrib_memregister_attributeset_vars_attributes
attributes_to_termfree_attributerenumber_vars_attributesterm_to_attributes
build_attr_termget_attributereplace_int_attributetransfer_inheritable_attributes
copy_attributesget_int_attributereplace_term_attributezap_attributes
copy_inheritable_attributesget_string_attributeset_int_attribute
declare_term_attribute_inheritableget_term_attributeset_string_attribute
exists_int_attributep_attrib_memset_term_attribute

Details


int attribute_name_to_id(char *name);
Given an attribute name, return the attribute ID which is used for the "get" and "set" operations. Return -1 if the name has not been registered with "register_attribute".
Term attributes_to_term(Attribute a, char *operator);
This routine takes a list of attributes and constructs a term representation. It is a right-associated binary tree with Term forms of the attributes at the leaves.
Term build_attr_term(Attribute a);
Given an attribute, build (and return) a term representation of it. The name of the attribute will be the (unary) function symbol, and the value will be the arggment.

This is typically used for printing attributes.


Attribute copy_attributes(Attribute a);
This routine copies a list of attributes.
Attribute copy_inheritable_attributes(Attribute a);
Given a list of attributes, this routine copies and returns the inheritable attributes.
void declare_term_attribute_inheritable(int id);
This routine makes a term attribute (which has already been registered) inheritable. This usually means that when the clause to which the attribute is attached begets a child, the child gets a copy of the instantiated attribute. This was designed for answer literals and ordering constraints.
BOOL exists_int_attribute(Attribute a, int id);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, INT_MAX is returned.

A fatal error occurs if the ID does not refer to an integer type attribute (see register_attribute).


void fprint_attrib_mem(FILE *fp, int heading);
This routine prints (to FILE *fp) memory usage statistics for data types associated with attributes. The Boolean argument heading tells whether to print a heading on the table.
void free_attribute(Attribute p);

Attribute get_attribute(void);

int get_int_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, INT_MAX is returned.

A fatal error occurs if the ID does not refer to an integer type attribute (see register_attribute).


char *get_string_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, NULL is returned.

A fatal error occurs if the ID does not refer to a string type attribute (see register_attribute).


Term get_term_attribute(Attribute a, int id, int n);
This routine gets the n-th (counting from 1) attribute value associated with an attribute ID. If nothing matches, NULL is returned.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute).


void p_attrib_mem();
This routine prints (to stdout) memory usage statistics for data types associated with attributes.
int register_attribute(char *name, Attribute_type type);
This routine associates an attribute name with an attribute type and returns an integer ID to be used with the attribute operations (set, get, etc).
void renumber_vars_attributes(Attribute attrs, int vmap[], int max_vars);
This routine renumbers the variables in the inheritable attribute terms.
void replace_int_attribute(Attribute a, int id, int val, int n);
This routine replaces that n-th int attribute for given attribute ID.

A fatal error occurs if the ID does not refer to an int type attribute (see register_attribute), or if there are not n attributes identified by ID.


void replace_term_attribute(Attribute a, int id, Term val, int n);
This routine replaces that n-th term attribute for given ID. The term that is already there is zapped, and the new term is NOT copied.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute), or if there are not n attributes identified by ID.


Attribute set_int_attribute(Attribute a, int id, int val);
This routine appends an pair to a list of attributes.

A fatal error occurs if the ID does not refer to an integer type attribute (see register_attribute).


Attribute set_string_attribute(Attribute a, int id, char *val);
This routine appends an pair to a list of attributes. The string is not copied.

A fatal error occurs if the ID does not refer to a string type attribute (see register_attribute).


Attribute set_term_attribute(Attribute a, int id, Term val);
This routine appends an pair to a list of attributes. The term is not copied.

A fatal error occurs if the ID does not refer to a Term type attribute (see register_attribute).


void set_vars_attributes(Attribute attrs, char *vnames[], int max_vars);
This routine sets the variables in the inheritable attribute terms.
Attribute term_to_attributes(Term t, char *operator);
This routine takes a term representing a list of attributes and builds list of attributes. The input term form is a binary term, constructed with the given operator, with the attributes at the leaves. For example,
    label("hi there!") # answer(XGK(x,y,z)) # hint_wt(32)
If anuthing goes wrong, a fatal error occurs.
Attribute transfer_inheritable_attributes(Attribute parent_attr,
			   Context subst,
			   Attribute child_attr);
This takes (1) a list of attributes from a (parent) clause, (2) an associated substitution, and (3) a list of attributes from a (child) clause. Any inheritable attributes on the parent list are instantiated and appended to the child's attributes. The list of child attributes is returned.
void zap_attributes(Attribute a);
This routine frees a list of attributes and any associated memory. In particular, the terms in term attributes are zapped.

Public Definitions in File attrib.h

typedef enum { INT_ATTRIBUTE,
	       STRING_ATTRIBUTE,
               TERM_ATTRIBUTE
             } Attribute_type;

typedef struct attribute * Attribute;

typedef union {int i; char *s; Term t;} Atype;


Introduction

This package is about lists of attributes. Each attribute is a pair (attribute-id, attribute-value). Each attribute-id is associated with a data type.

To use an attribute, you first have to call register_attribute(), giving the name type of the attribute, and it returns an ID to be used with the "set" and "get" operations.

For example,

  int label_attr = register_attribute("label", STRING_ATTRIBUTE);
  ...
  Attribute a = set_string_attribute(NULL, label_attr, "clause_32");
  ...
  char *s = get_string_attribute(a, label_attr, 1);

These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.