Index: uspace/app/sbi/src/stree.c
===================================================================
--- uspace/app/sbi/src/stree.c	(revision 23de644e12ee218601dd193540374b779a6364d7)
+++ uspace/app/sbi/src/stree.c	(revision 883fedc17e531dbc742cf77dc44e3bff56c53dce)
@@ -37,4 +37,8 @@
 #include "stree.h"
 
+/** Allocate new module.
+ *
+ * @return	New module
+ */
 stree_module_t *stree_module_new(void)
 {
@@ -51,4 +55,9 @@
 }
 
+/** Allocate new module member.
+ *
+ * @param mc	Module member class
+ * @return	New module member
+ */
 stree_modm_t *stree_modm_new(modm_class_t mc)
 {
@@ -65,4 +74,9 @@
 }
 
+/** Allocate new CSI.
+ *
+ * @param cc	CSI class
+ * @return	New CSI
+ */
 stree_csi_t *stree_csi_new(csi_class_t cc)
 {
@@ -83,4 +97,9 @@
 }
 
+/** Allocate new CSI member.
+ *
+ * @param cc	CSI member class
+ * @return	New CSI member
+ */
 stree_csimbr_t *stree_csimbr_new(csimbr_class_t cc)
 {
@@ -97,4 +116,25 @@
 }
 
+/** Allocate new member delegate.
+ *
+ * @return	New member delegate
+ */
+stree_deleg_t *stree_deleg_new(void)
+{
+	stree_deleg_t *deleg;
+
+	deleg = calloc(1, sizeof(stree_deleg_t));
+	if (deleg == NULL) {
+		printf("Memory allocation failed.\n");
+		exit(1);
+	}
+
+	return deleg;
+}
+
+/** Allocate new member function.
+ *
+ * @return	New member function
+ */
 stree_fun_t *stree_fun_new(void)
 {
@@ -110,4 +150,8 @@
 }
 
+/** Allocate new member variable.
+ *
+ * @return	New member variable
+ */
 stree_var_t *stree_var_new(void)
 {
@@ -123,4 +167,8 @@
 }
 
+/** Allocate new property.
+ *
+ * @return	New property
+ */
 stree_prop_t *stree_prop_new(void)
 {
@@ -136,4 +184,26 @@
 }
 
+/** Allocate new type argument.
+ *
+ * @return	New type argument
+ */
+stree_targ_t *stree_targ_new(void)
+{
+	stree_targ_t *targ;
+
+	targ = calloc(1, sizeof(stree_targ_t));
+	if (targ == NULL) {
+		printf("Memory allocation failed.\n");
+		exit(1);
+	}
+
+	return targ;
+}
+
+/** Allocate new symbol attribute.
+ *
+ * @param sac	Symbol attribute class
+ * @return	New symbol attribute
+ */
 stree_symbol_attr_t *stree_symbol_attr_new(symbol_attr_class_t sac)
 {
@@ -150,4 +220,8 @@
 }
 
+/** Allocate new procedure.
+ *
+ * @return	New procedure
+ */
 stree_proc_t *stree_proc_new(void)
 {
@@ -163,4 +237,8 @@
 }
 
+/** Allocate new procedure argument.
+ *
+ * @return	New procedure argument
+ */
 stree_proc_arg_t *stree_proc_arg_new(void)
 {
@@ -176,4 +254,26 @@
 }
 
+/** Allocate new function signature.
+ *
+ * @return	New procedure argument
+ */
+stree_fun_sig_t *stree_fun_sig_new(void)
+{
+	stree_fun_sig_t *fun_sig;
+
+	fun_sig = calloc(1, sizeof(stree_fun_sig_t));
+	if (fun_sig == NULL) {
+		printf("Memory allocation failed.\n");
+		exit(1);
+	}
+
+	return fun_sig;
+}
+
+/** Allocate new procedure argument attribute.
+ *
+ * @param	Argument attribute class
+ * @return	New procedure argument attribute
+ */
 stree_arg_attr_t *stree_arg_attr_new(arg_attr_class_t aac)
 {
@@ -190,4 +290,9 @@
 }
 
+/** Allocate new statement.
+ *
+ * @param sc	Statement class
+ * @return	New statement
+ */
 stree_stat_t *stree_stat_new(stat_class_t sc)
 {
@@ -204,4 +309,8 @@
 }
 
+/** Allocate new local variable declaration.
+ *
+ * @return	New local variable declaration
+ */
 stree_vdecl_t *stree_vdecl_new(void)
 {
@@ -217,4 +326,8 @@
 }
 
+/** Allocate new @c if statement.
+ *
+ * @return	New @c if statement
+ */
 stree_if_t *stree_if_new(void)
 {
@@ -230,4 +343,8 @@
 }
 
+/** Allocate new @c while statement.
+ *
+ * @return	New @c while statement
+ */
 stree_while_t *stree_while_new(void)
 {
@@ -243,4 +360,8 @@
 }
 
+/** Allocate new @c for statement.
+ *
+ * @return	New @c for statement
+ */
 stree_for_t *stree_for_new(void)
 {
@@ -256,4 +377,8 @@
 }
 
+/** Allocate new @c raise statement.
+ *
+ * @return	New @c raise statement
+ */
 stree_raise_t *stree_raise_new(void)
 {
@@ -269,4 +394,8 @@
 }
 
+/** Allocate new @c return statement.
+ *
+ * @return	New @c return statement
+ */
 stree_return_t *stree_return_new(void)
 {
@@ -282,4 +411,8 @@
 }
 
+/** Allocate new with-except-finally statement.
+ *
+ * @return	New with-except-finally statement.
+ */
 stree_wef_t *stree_wef_new(void)
 {
@@ -295,4 +428,8 @@
 }
 
+/** Allocate new expression statement.
+ *
+ * @return	New expression statement
+ */
 stree_exps_t *stree_exps_new(void)
 {
@@ -308,4 +445,8 @@
 }
 
+/** Allocate new @c except clause.
+ *
+ * @return	New @c except clause
+ */
 stree_except_t *stree_except_new(void)
 {
@@ -321,4 +462,8 @@
 }
 
+/** Allocate new statement block.
+ *
+ * @return	New statement block
+ */
 stree_block_t *stree_block_new(void)
 {
@@ -334,4 +479,9 @@
 }
 
+/** Allocate new expression.
+ *
+ * @param ec	Expression class
+ * @return	New expression
+ */
 stree_expr_t *stree_expr_new(expr_class_t ec)
 {
@@ -348,4 +498,9 @@
 }
 
+/** Allocate new assignment.
+ *
+ * @param ac	Assignment class
+ * @return	New assignment
+ */
 stree_assign_t *stree_assign_new(assign_class_t ac)
 {
@@ -362,4 +517,8 @@
 }
 
+/** Allocate new binary operation.
+ *
+ * @return	New binary operation
+ */
 stree_binop_t *stree_binop_new(binop_class_t bc)
 {
@@ -376,4 +535,9 @@
 }
 
+/** Allocate new unary operation.
+ *
+ * @param uc	Unary operation class
+ * @return	New unary operation
+ */
 stree_unop_t *stree_unop_new(unop_class_t uc)
 {
@@ -390,4 +554,8 @@
 }
 
+/** Allocate new @c new operation.
+ *
+ * @return	New @c new operation
+ */
 stree_new_t *stree_new_new(void)
 {
@@ -403,4 +571,8 @@
 }
 
+/** Allocate new .
+ *
+ * @return	New 
+ */
 stree_access_t *stree_access_new(void)
 {
@@ -416,4 +588,8 @@
 }
 
+/** Allocate new function call operation.
+ *
+ * @return	New function call operation
+ */
 stree_call_t *stree_call_new(void)
 {
@@ -429,4 +605,8 @@
 }
 
+/** Allocate new indexing operation.
+ *
+ * @return	New indexing operation
+ */
 stree_index_t *stree_index_new(void)
 {
@@ -442,4 +622,8 @@
 }
 
+/** Allocate new as conversion.
+ *
+ * @return	New as conversion
+ */
 stree_as_t *stree_as_new(void)
 {
@@ -455,4 +639,25 @@
 }
 
+/** Allocate new boxing operation.
+ *
+ * @return	New boxing operation
+ */
+stree_box_t *stree_box_new(void)
+{
+	stree_box_t *box_expr;
+
+	box_expr = calloc(1, sizeof(stree_box_t));
+	if (box_expr == NULL) {
+		printf("Memory allocation failed.\n");
+		exit(1);
+	}
+
+	return box_expr;
+}
+
+/** Allocate new name reference operation.
+ *
+ * @return	New name reference operation
+ */
 stree_nameref_t *stree_nameref_new(void)
 {
@@ -468,4 +673,8 @@
 }
 
+/** Allocate new identifier.
+ *
+ * @return	New identifier
+ */
 stree_ident_t *stree_ident_new(void)
 {
@@ -481,4 +690,9 @@
 }
 
+/** Allocate new literal.
+ *
+ * @param ltc	Literal class
+ * @return	New literal
+ */
 stree_literal_t *stree_literal_new(literal_class_t ltc)
 {
@@ -495,4 +709,8 @@
 }
 
+/** Allocate new @c self reference.
+ *
+ * @return	New @c self reference
+ */
 stree_self_ref_t *stree_self_ref_new(void)
 {
@@ -508,4 +726,8 @@
 }
 
+/** Allocate new type expression
+ *
+ * @return	New type expression
+ */
 stree_texpr_t *stree_texpr_new(texpr_class_t tc)
 {
@@ -522,4 +744,8 @@
 }
 
+/** Allocate new type access operation.
+ *
+ * @return	New type access operation
+ */
 stree_taccess_t *stree_taccess_new(void)
 {
@@ -535,4 +761,8 @@
 }
 
+/** Allocate new type application operation.
+ *
+ * @return	New type application operation
+ */
 stree_tapply_t *stree_tapply_new(void)
 {
@@ -548,4 +778,8 @@
 }
 
+/** Allocate new type indexing operation.
+ *
+ * @return	New type indexing operation
+ */
 stree_tindex_t *stree_tindex_new(void)
 {
@@ -561,4 +795,8 @@
 }
 
+/** Allocate new type literal.
+ *
+ * @return	New type literal
+ */
 stree_tliteral_t *stree_tliteral_new(tliteral_class_t tlc)
 {
@@ -575,4 +813,8 @@
 }
 
+/** Allocate new type name reference.
+ *
+ * @return	New type name reference
+ */
 stree_tnameref_t *stree_tnameref_new(void)
 {
@@ -588,4 +830,8 @@
 }
 
+/** Allocate new symbol.
+ *
+ * @return	New symbol
+ */
 stree_symbol_t *stree_symbol_new(symbol_class_t sc)
 {
@@ -602,4 +848,8 @@
 }
 
+/** Allocate new program.
+ *
+ * @return	New program
+ */
 stree_program_t *stree_program_new(void)
 {
@@ -615,5 +865,10 @@
 }
 
-/** Determine if @a symbol has attribute of class @a sac. */
+/** Determine if @a symbol has attribute of class @a sac.
+ *
+ * @param symbol	Symbol
+ * @param sac		Symbol attribute class
+ * @return		@c b_true if yes, @c b_false if no.
+ */
 bool_t stree_symbol_has_attr(stree_symbol_t *symbol, symbol_attr_class_t sac)
 {
@@ -633,5 +888,10 @@
 }
 
-/** Determine if argument @a arg has attribute of class @a aac. */
+/** Determine if argument @a arg has attribute of class @a aac.
+ *
+ * @param arg		Formal procedure argument
+ * @param aac		Argument attribute class
+ * @return		@c b_true if yes, @c b_false if no.
+ */
 bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac)
 {
@@ -653,4 +913,6 @@
 /** Determine wheter @a a is derived (transitively) from @a b.
  *
+ * XXX This does not work right with generics.
+ *
  * @param a	Derived CSI.
  * @param b	Base CSI.
@@ -673,2 +935,26 @@
 	return b_false;
 }
+
+/** Search for CSI type argument of the given name.
+ *
+ * @param csi		CSI to look in.
+ * @param ident		Identifier of the type argument.
+ * @return		Type argument definition or @c NULL if not found.
+ */
+stree_targ_t *stree_csi_find_targ(stree_csi_t *csi, stree_ident_t *ident)
+{
+	list_node_t *targ_n;
+	stree_targ_t *targ;
+
+	targ_n = list_first(&csi->targ);
+	while (targ_n != NULL) {
+		targ = list_node_data(targ_n, stree_targ_t *);
+		if (targ->name->sid == ident->sid)
+			return targ;
+
+		targ_n = list_next(&csi->targ, targ_n);
+	}
+
+	/* No match */
+	return NULL;
+}
