src/tds/tds.c
/* Add an entity (var, param or func) to the current scope
 */
Add an entity (var, param or func) to the current scope
Add an entity ( var param or func ) to the current scope
void addEntity(ANTLR3_BASE_TREE *scope) {
  entity *e;
  debug(
    DEBUG_TDS,
    "\033[01;36mentity\033[0m %s",
    scope->toString(scope->getChild(scope, 0))->chars
  );
  switch (scope->getType(scope)) {
    case VAR_DECLARATION:
    case PARAM:
      e = buildVarEntity(scope);
      break;
    case FUNC_DECLARATION:
      e = buildFuncEntity(scope);
      break;
  }
  if (isDuplicate(e->name)) {
    error("An entity with the name %s allready exists", e->name);
    free(e);
    return;
  };
  e->brother = NULL;
  if (TDS->entities != NULL)
    e->brother = TDS->entities;
  e->scope = TDS;
  TDS->entities = e;
}
void addEntity ( ANTLR3_BASE_TREE * scope ) { entity * e ; debug ( DEBUG_TDS , " \033 \033 " , scope -> toString ( scope -> getChild ( scope , 0 ) ) -> chars ) ; switch ( scope -> getType ( scope ) ) { case VAR_DECLARATION : case PARAM : e = buildVarEntity ( scope ) ; break ; case FUNC_DECLARATION : e = buildFuncEntity ( scope ) ; break ; } if ( isDuplicate ( e -> name ) ) { error ( " " , e -> name ) ; free ( e ) ; return ; } ; e -> brother = NULL ; if ( TDS -> entities != NULL ) e -> brother = TDS -> entities ; e -> scope = TDS ; TDS -> entities = e ; }
Add an entity (var, param or func) to the current scope
Add an entity ( var param or func ) to the current scope