Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wsstree.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  WsListItemRec
struct  WsListRec
struct  WsNamespaceRec
struct  WsPragmaUseRec
struct  WsPragmaMetaBodyRec
struct  WsFunctionRec
struct  WsFunctionHashRec
struct  WsExpressionRec
struct  WsVarDecRec
struct  WsFormalParmRec
struct  WsStatementRec

Typedefs

typedef WsListItemRec WsListItem
typedef WsListRec WsList
typedef WsNamespaceRec WsNamespace
typedef WsPragmaUseRec WsPragmaUse
typedef WsPragmaMetaBodyRec WsPragmaMetaBody
typedef WsFunctionRec WsFunction
typedef WsFunctionHashRec WsFunctionHash
typedef WsExpressionRec WsExpression
typedef WsVarDecRec WsVarDec
typedef WsFormalParmRec WsFormalParm
typedef WsStatementRec WsStatement

Enumerations

enum  WsExpressionType {
  WS_EXPR_COMMA, WS_EXPR_ASSIGN, WS_EXPR_CONDITIONAL, WS_EXPR_LOGICAL,
  WS_EXPR_BINARY, WS_EXPR_UNARY, WS_EXPR_UNARY_VAR, WS_EXPR_POSTFIX_VAR,
  WS_EXPR_CALL, WS_EXPR_SYMBOL, WS_EXPR_CONST_INVALID, WS_EXPR_CONST_TRUE,
  WS_EXPR_CONST_FALSE, WS_EXPR_CONST_INTEGER, WS_EXPR_CONST_FLOAT, WS_EXPR_CONST_STRING
}
enum  WsStatementType {
  WS_STMT_BLOCK, WS_STMT_VARIABLE, WS_STMT_EMPTY, WS_STMT_EXPR,
  WS_STMT_IF, WS_STMT_FOR, WS_STMT_WHILE, WS_STMT_CONTINUE,
  WS_STMT_BREAK, WS_STMT_RETURN
}

Functions

WsListws_list_new (WsCompilerPtr compiler)
void ws_list_append (WsCompilerPtr compiler, WsList *list, void *value)
WsHashPtr ws_variable_hash_create (void)
WsNamespacews_variable_define (WsCompilerPtr compiler, WsUInt32 line, WsBool variablep, char *name)
WsNamespacews_variable_lookup (WsCompilerPtr compiler, char *name)
WsHashPtr ws_pragma_use_hash_create (void)
void ws_pragma_use (WsCompilerPtr compiler, WsUInt32 line, char *identifier, WsUtf8String *url)
WsPragmaMetaBodyws_pragma_meta_body (WsCompilerPtr compiler, WsUtf8String *property_name, WsUtf8String *content, WsUtf8String *scheme)
void ws_pragma_meta_body_free (WsCompilerPtr compiler, WsPragmaMetaBody *mb)
WsHashPtr ws_function_hash_create (void)
WsFunctionHashws_function_hash (WsCompilerPtr compiler, char *name)
void ws_function (WsCompilerPtr compiler, WsBool externp, char *name, WsUInt32 line, WsList *params, WsList *block)
void ws_expr_linearize (WsCompilerPtr compiler, WsExpression *expr)
WsExpressionws_expr_comma (WsCompilerPtr compiler, WsUInt32 line, WsExpression *left, WsExpression *right)
WsExpressionws_expr_assign (WsCompilerPtr compiler, WsUInt32 line, char *identifier, int op, WsExpression *expr)
WsExpressionws_expr_conditional (WsCompilerPtr compiler, WsUInt32 line, WsExpression *e_cond, WsExpression *e_then, WsExpression *e_else)
WsExpressionws_expr_logical (WsCompilerPtr compiler, WsUInt32 line, int type, WsExpression *left, WsExpression *right)
WsExpressionws_expr_binary (WsCompilerPtr compiler, WsUInt32 line, int type, WsExpression *left, WsExpression *right)
WsExpressionws_expr_unary (WsCompilerPtr compiler, WsUInt32 line, int type, WsExpression *expr)
WsExpressionws_expr_unary_var (WsCompilerPtr compiler, WsUInt32 line, WsBool addp, char *variable)
WsExpressionws_expr_postfix_var (WsCompilerPtr compiler, WsUInt32 line, WsBool addp, char *variable)
WsExpressionws_expr_call (WsCompilerPtr compiler, WsUInt32 linenum, int type, char *base, char *name, WsList *arguments)
WsExpressionws_expr_symbol (WsCompilerPtr compiler, WsUInt32 linenum, char *identifier)
WsExpressionws_expr_const_invalid (WsCompilerPtr compiler, WsUInt32 linenum)
WsExpressionws_expr_const_true (WsCompilerPtr compiler, WsUInt32 linenum)
WsExpressionws_expr_const_false (WsCompilerPtr compiler, WsUInt32 linenum)
WsExpressionws_expr_const_integer (WsCompilerPtr compiler, WsUInt32 linenum, WsUInt32 ival)
WsExpressionws_expr_const_float (WsCompilerPtr compiler, WsUInt32 linenum, WsFloat fval)
WsExpressionws_expr_const_string (WsCompilerPtr compiler, WsUInt32 linenum, WsUtf8String *string)
WsVarDecws_variable_declaration (WsCompilerPtr compiler, char *name, WsExpression *expr)
WsFormalParmws_formal_parameter (WsCompilerPtr compiler, WsUInt32 line, char *name)
void ws_stmt_linearize (WsCompilerPtr compiler, WsStatement *stmt)
WsStatementws_stmt_block (WsCompilerPtr compiler, WsUInt32 first_line, WsUInt32 last_line, WsList *block)
WsStatementws_stmt_variable (WsCompilerPtr compiler, WsUInt32 line, WsList *variables)
WsStatementws_stmt_empty (WsCompilerPtr compiler, WsUInt32 line)
WsStatementws_stmt_expr (WsCompilerPtr compiler, WsUInt32 line, WsExpression *expr)
WsStatementws_stmt_if (WsCompilerPtr compiler, WsUInt32 line, WsExpression *expr, WsStatement *s_then, WsStatement *s_else)
WsStatementws_stmt_for (WsCompilerPtr compiler, WsUInt32 line, WsList *init, WsExpression *e1, WsExpression *e2, WsExpression *e3, WsStatement *stmt)
WsStatementws_stmt_while (WsCompilerPtr compiler, WsUInt32 line, WsExpression *expr, WsStatement *stmt)
WsStatementws_stmt_continue (WsCompilerPtr compiler, WsUInt32 line)
WsStatementws_stmt_break (WsCompilerPtr compiler, WsUInt32 line)
WsStatementws_stmt_return (WsCompilerPtr compiler, WsUInt32 line, WsExpression *expr)


Typedef Documentation

typedef struct WsExpressionRec WsExpression
 

Definition at line 389 of file wsstree.h.

Referenced by expr_alloc(), ws_expr_assign(), ws_expr_binary(), ws_expr_call(), ws_expr_comma(), ws_expr_conditional(), ws_expr_const_false(), ws_expr_const_float(), ws_expr_const_integer(), ws_expr_const_invalid(), ws_expr_const_string(), ws_expr_const_true(), ws_expr_linearize(), ws_expr_logical(), ws_expr_postfix_var(), ws_expr_symbol(), ws_expr_unary(), ws_expr_unary_var(), ws_stmt_expr(), ws_stmt_for(), ws_stmt_if(), ws_stmt_return(), ws_stmt_while(), and ws_variable_declaration().

typedef struct WsFormalParmRec WsFormalParm
 

Definition at line 496 of file wsstree.h.

Referenced by compile_stream(), ws_formal_parameter(), and yyparse().

typedef struct WsFunctionRec WsFunction
 

Definition at line 209 of file wsstree.h.

Referenced by compile_stream(), sort_functions_cmp(), and ws_function().

typedef struct WsFunctionHashRec WsFunctionHash
 

Definition at line 225 of file wsstree.h.

Referenced by compile_stream(), ws_expr_linearize(), ws_function(), ws_function_hash(), and yyparse().

typedef struct WsListRec WsList
 

Definition at line 99 of file wsstree.h.

Referenced by linearize_variable_init(), ws_expr_call(), ws_function(), ws_list_append(), ws_list_new(), ws_stmt_block(), ws_stmt_for(), and ws_stmt_variable().

typedef struct WsListItemRec WsListItem
 

Definition at line 83 of file wsstree.h.

Referenced by compile_stream(), linearize_variable_init(), ws_expr_linearize(), ws_list_append(), and ws_stmt_linearize().

typedef struct WsNamespaceRec WsNamespace
 

Definition at line 122 of file wsstree.h.

Referenced by linearize_variable_init(), ws_expr_linearize(), ws_variable_define(), and ws_variable_lookup().

typedef struct WsPragmaMetaBodyRec WsPragmaMetaBody
 

Definition at line 181 of file wsstree.h.

Referenced by ws_pragma_meta_body(), and ws_pragma_meta_body_free().

typedef struct WsPragmaUseRec WsPragmaUse
 

Definition at line 156 of file wsstree.h.

Referenced by ws_expr_linearize(), and ws_pragma_use().

typedef struct WsStatementRec WsStatement
 

Definition at line 560 of file wsstree.h.

Referenced by stmt_alloc(), ws_stmt_block(), ws_stmt_break(), ws_stmt_continue(), ws_stmt_empty(), ws_stmt_expr(), ws_stmt_for(), ws_stmt_if(), ws_stmt_linearize(), ws_stmt_return(), ws_stmt_variable(), and ws_stmt_while().

typedef struct WsVarDecRec WsVarDec
 

Definition at line 483 of file wsstree.h.

Referenced by linearize_variable_init(), and ws_variable_declaration().


Enumeration Type Documentation

enum WsExpressionType
 

Enumeration values:
WS_EXPR_COMMA 
WS_EXPR_ASSIGN 
WS_EXPR_CONDITIONAL 
WS_EXPR_LOGICAL 
WS_EXPR_BINARY 
WS_EXPR_UNARY 
WS_EXPR_UNARY_VAR 
WS_EXPR_POSTFIX_VAR 
WS_EXPR_CALL 
WS_EXPR_SYMBOL 
WS_EXPR_CONST_INVALID 
WS_EXPR_CONST_TRUE 
WS_EXPR_CONST_FALSE 
WS_EXPR_CONST_INTEGER 
WS_EXPR_CONST_FLOAT 
WS_EXPR_CONST_STRING 

Definition at line 251 of file wsstree.h.

00252 {
00253     WS_EXPR_COMMA,
00254     WS_EXPR_ASSIGN,
00255     WS_EXPR_CONDITIONAL,
00256     WS_EXPR_LOGICAL,
00257     WS_EXPR_BINARY,
00258     WS_EXPR_UNARY,
00259     WS_EXPR_UNARY_VAR,
00260     WS_EXPR_POSTFIX_VAR,
00261     WS_EXPR_CALL,
00262     WS_EXPR_SYMBOL,
00263     WS_EXPR_CONST_INVALID,
00264     WS_EXPR_CONST_TRUE,
00265     WS_EXPR_CONST_FALSE,
00266     WS_EXPR_CONST_INTEGER,
00267     WS_EXPR_CONST_FLOAT,
00268     WS_EXPR_CONST_STRING
00269 } WsExpressionType;

enum WsStatementType
 

Enumeration values:
WS_STMT_BLOCK 
WS_STMT_VARIABLE 
WS_STMT_EMPTY 
WS_STMT_EXPR 
WS_STMT_IF 
WS_STMT_FOR 
WS_STMT_WHILE 
WS_STMT_CONTINUE 
WS_STMT_BREAK 
WS_STMT_RETURN 

Definition at line 506 of file wsstree.h.

00507 {
00508     WS_STMT_BLOCK,
00509     WS_STMT_VARIABLE,
00510     WS_STMT_EMPTY,
00511     WS_STMT_EXPR,
00512     WS_STMT_IF,
00513     WS_STMT_FOR,
00514     WS_STMT_WHILE,
00515     WS_STMT_CONTINUE,
00516     WS_STMT_BREAK,
00517     WS_STMT_RETURN
00518 } WsStatementType;


Function Documentation

WsExpression* ws_expr_assign WsCompilerPtr  compiler,
WsUInt32  line,
char *  identifier,
int  op,
WsExpression expr
 

Definition at line 903 of file wsstree.c.

References WsExpressionRec::assign, WsExpressionRec::expr, expr_alloc(), WsExpressionRec::identifier, WsExpressionRec::op, WsCompilerRec::pool_stree, WsExpressionRec::u, ws_error_memory(), WS_EXPR_ASSIGN, ws_f_strdup(), ws_lexer_free_block(), WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00905 {
00906     WsExpression *e = expr_alloc(compiler, WS_EXPR_ASSIGN, line);
00907 
00908     if (e) {
00909         e->u.assign.identifier = ws_f_strdup(compiler->pool_stree, identifier);
00910         if (e->u.assign.identifier == NULL)
00911             ws_error_memory(compiler);
00912 
00913         e->u.assign.op = op;
00914         e->u.assign.expr = expr;
00915     }
00916 
00917     /* Free the identifier symbol since it allocated from the system
00918        heap. */
00919     ws_lexer_free_block(compiler, identifier);
00920 
00921     return e;
00922 }

Here is the call graph for this function:

WsExpression* ws_expr_binary WsCompilerPtr  compiler,
WsUInt32  line,
int  type,
WsExpression left,
WsExpression right
 

Definition at line 956 of file wsstree.c.

References WsExpressionRec::binary, expr_alloc(), WsExpressionRec::left, WsExpressionRec::right, WsExpressionRec::type, WsExpressionRec::u, WS_EXPR_BINARY, WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00958 {
00959     WsExpression *expr = expr_alloc(compiler, WS_EXPR_BINARY, line);
00960 
00961     if (expr) {
00962         expr->u.binary.type = type;
00963         expr->u.binary.left = left;
00964         expr->u.binary.right = right;
00965     }
00966 
00967     return expr;
00968 }

Here is the call graph for this function:

WsExpression* ws_expr_call WsCompilerPtr  compiler,
WsUInt32  linenum,
int  type,
char *  base,
char *  name,
WsList arguments
 

Referenced by yyparse().

WsExpression* ws_expr_comma WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression left,
WsExpression right
 

Definition at line 889 of file wsstree.c.

References WsExpressionRec::comma, expr_alloc(), WsExpressionRec::left, WsExpressionRec::right, WsExpressionRec::u, WS_EXPR_COMMA, WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00891 {
00892     WsExpression *expr = expr_alloc(compiler, WS_EXPR_COMMA, line);
00893 
00894     if (expr) {
00895         expr->u.comma.left = left;
00896         expr->u.comma.right = right;
00897     }
00898 
00899     return expr;
00900 }

Here is the call graph for this function:

WsExpression* ws_expr_conditional WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression e_cond,
WsExpression e_then,
WsExpression e_else
 

Definition at line 925 of file wsstree.c.

References WsExpressionRec::conditional, WsExpressionRec::e_cond, WsExpressionRec::e_else, WsExpressionRec::e_then, expr_alloc(), WsExpressionRec::u, WS_EXPR_CONDITIONAL, WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00928 {
00929     WsExpression *e = expr_alloc(compiler, WS_EXPR_CONDITIONAL, line);
00930 
00931     if (e) {
00932         e->u.conditional.e_cond = e_cond;
00933         e->u.conditional.e_then = e_then;
00934         e->u.conditional.e_else = e_else;
00935     }
00936 
00937     return e;
00938 }

Here is the call graph for this function:

WsExpression* ws_expr_const_false WsCompilerPtr  compiler,
WsUInt32  linenum
 

Referenced by yyparse().

WsExpression* ws_expr_const_float WsCompilerPtr  compiler,
WsUInt32  linenum,
WsFloat  fval
 

Referenced by yyparse().

WsExpression* ws_expr_const_integer WsCompilerPtr  compiler,
WsUInt32  linenum,
WsUInt32  ival
 

Referenced by yyparse().

WsExpression* ws_expr_const_invalid WsCompilerPtr  compiler,
WsUInt32  linenum
 

Referenced by yyparse().

WsExpression* ws_expr_const_string WsCompilerPtr  compiler,
WsUInt32  linenum,
WsUtf8String string
 

Referenced by yyparse().

WsExpression* ws_expr_const_true WsCompilerPtr  compiler,
WsUInt32  linenum
 

Referenced by yyparse().

void ws_expr_linearize WsCompilerPtr  compiler,
WsExpression expr
 

Referenced by linearize_variable_init(), ws_expr_linearize(), and ws_stmt_linearize().

WsExpression* ws_expr_logical WsCompilerPtr  compiler,
WsUInt32  line,
int  type,
WsExpression left,
WsExpression right
 

Definition at line 941 of file wsstree.c.

References expr_alloc(), WsExpressionRec::left, WsExpressionRec::logical, WsExpressionRec::right, WsExpressionRec::type, WsExpressionRec::u, WS_EXPR_LOGICAL, WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00943 {
00944     WsExpression *expr = expr_alloc(compiler, WS_EXPR_LOGICAL, line);
00945 
00946     if (expr) {
00947         expr->u.logical.type = type;
00948         expr->u.logical.left = left;
00949         expr->u.logical.right = right;
00950     }
00951 
00952     return expr;
00953 }

Here is the call graph for this function:

WsExpression* ws_expr_postfix_var WsCompilerPtr  compiler,
WsUInt32  line,
WsBool  addp,
char *  variable
 

Definition at line 1010 of file wsstree.c.

References WsExpressionRec::addp, expr_alloc(), WsCompilerRec::pool_stree, WsExpressionRec::postfix_var, WsExpressionRec::u, WsExpressionRec::variable, ws_error_memory(), WS_EXPR_POSTFIX_VAR, ws_f_strdup(), ws_lexer_free_block(), WsCompilerPtr, and WsExpression.

Referenced by yyparse().

01012 {
01013     WsExpression *expr = expr_alloc(compiler, WS_EXPR_POSTFIX_VAR, line);
01014 
01015     if (expr) {
01016         expr->u.postfix_var.addp = addp;
01017         expr->u.postfix_var.variable = ws_f_strdup(compiler->pool_stree,
01018                                        variable);
01019         if (expr->u.postfix_var.variable == NULL)
01020             ws_error_memory(compiler);
01021     }
01022     ws_lexer_free_block(compiler, variable);
01023 
01024     return expr;
01025 }

Here is the call graph for this function:

WsExpression* ws_expr_symbol WsCompilerPtr  compiler,
WsUInt32  linenum,
char *  identifier
 

Referenced by yyparse().

WsExpression* ws_expr_unary WsCompilerPtr  compiler,
WsUInt32  line,
int  type,
WsExpression expr
 

Definition at line 971 of file wsstree.c.

References WsExpressionRec::expr, expr_alloc(), WsExpressionRec::integer, WsExpressionRec::sign, WsExpressionRec::type, type, WsExpressionRec::u, WsExpressionRec::unary, WS_ASM_UMINUS, WS_EXPR_UNARY, WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00973 {
00974     WsExpression *expr;
00975 
00976     /* Handle negative integers here as a special case of constant folding,
00977      * in order to get -2147483648 right. */
00978     if (type == WS_ASM_UMINUS && expression->type == WS_EXPR_CONST_INTEGER) {
00979         expression->u.integer.sign = - expression->u.integer.sign;
00980         return expression;
00981     }
00982 
00983     expr = expr_alloc(compiler, WS_EXPR_UNARY, line);
00984     if (expr) {
00985         expr->u.unary.type = type;
00986         expr->u.unary.expr = expression;
00987     }
00988 
00989     return expr;
00990 }

Here is the call graph for this function:

WsExpression* ws_expr_unary_var WsCompilerPtr  compiler,
WsUInt32  line,
WsBool  addp,
char *  variable
 

Definition at line 993 of file wsstree.c.

References WsExpressionRec::addp, expr_alloc(), WsCompilerRec::pool_stree, WsExpressionRec::u, WsExpressionRec::unary_var, WsExpressionRec::variable, ws_error_memory(), WS_EXPR_UNARY_VAR, ws_f_strdup(), ws_lexer_free_block(), WsCompilerPtr, and WsExpression.

Referenced by yyparse().

00995 {
00996     WsExpression *expr = expr_alloc(compiler, WS_EXPR_UNARY_VAR, line);
00997 
00998     if (expr) {
00999         expr->u.unary_var.addp = addp;
01000         expr->u.unary_var.variable = ws_f_strdup(compiler->pool_stree, variable);
01001         if (expr->u.unary_var.variable == NULL)
01002             ws_error_memory(compiler);
01003     }
01004     ws_lexer_free_block(compiler, variable);
01005 
01006     return expr;
01007 }

Here is the call graph for this function:

WsFormalParm* ws_formal_parameter WsCompilerPtr  compiler,
WsUInt32  line,
char *  name
 

Definition at line 93 of file wsstree.c.

References WsFormalParmRec::line, WsFormalParmRec::name, WsCompilerRec::pool_stree, ws_error_memory(), ws_f_malloc(), WsCompilerPtr, and WsFormalParm.

Referenced by yyparse().

00095 {
00096     WsFormalParm *parm = ws_f_malloc(compiler->pool_stree, sizeof(*parm));
00097 
00098     if (parm == NULL)
00099         ws_error_memory(compiler);
00100     else {
00101         parm->line = line;
00102         parm->name = name;
00103     }
00104 
00105     return parm;
00106 }

Here is the call graph for this function:

void ws_function WsCompilerPtr  compiler,
WsBool  externp,
char *  name,
WsUInt32  line,
WsList params,
WsList block
 

Referenced by yyparse().

WsFunctionHash* ws_function_hash WsCompilerPtr  compiler,
char *  name
 

Definition at line 318 of file wsstree.c.

References WsCompilerRec::functions_hash, name, ws_calloc(), ws_error_memory(), ws_free(), ws_hash_get(), ws_hash_put(), WsCompilerPtr, and WsFunctionHash.

Referenced by compile_stream(), ws_expr_linearize(), ws_function(), and yyparse().

00319 {
00320     WsFunctionHash *i = ws_hash_get(compiler->functions_hash, name);
00321 
00322     if (i)
00323         return i;
00324 
00325     /* Must create a new mapping. */
00326 
00327     i = ws_calloc(1, sizeof(*i));
00328     if (i == NULL) {
00329         ws_error_memory(compiler);
00330         return NULL;
00331     }
00332 
00333     if (!ws_hash_put(compiler->functions_hash, name, i)) {
00334         ws_free(i);
00335         ws_error_memory(compiler);
00336         return NULL;
00337     }
00338 
00339     return i;
00340 }

Here is the call graph for this function:

WsHashPtr ws_function_hash_create void   ) 
 

Definition at line 312 of file wsstree.c.

References function_hash_destructor(), ws_hash_create(), and WsHashPtr.

Referenced by compile_stream().

00313 {
00314     return ws_hash_create(function_hash_destructor, NULL);
00315 }

Here is the call graph for this function:

void ws_list_append WsCompilerPtr  compiler,
WsList list,
void *  value
 

Referenced by yyparse().

WsList* ws_list_new WsCompilerPtr  compiler  ) 
 

Referenced by yyparse().

WsPragmaMetaBody* ws_pragma_meta_body WsCompilerPtr  compiler,
WsUtf8String property_name,
WsUtf8String content,
WsUtf8String scheme
 

Definition at line 271 of file wsstree.c.

References WsPragmaMetaBodyRec::property_name, ws_calloc(), ws_error_memory(), WsCompilerPtr, WsPragmaMetaBody, and WsUtf8String.

Referenced by yyparse().

00275 {
00276     WsPragmaMetaBody *mb = ws_calloc(1, sizeof(*mb));
00277 
00278     if (mb == NULL) {
00279         ws_error_memory(compiler);
00280         return NULL;
00281     }
00282 
00283     mb->property_name = property_name;
00284     mb->content = content;
00285     mb->scheme = scheme;
00286 
00287     return mb;
00288 }

Here is the call graph for this function:

void ws_pragma_meta_body_free WsCompilerPtr  compiler,
WsPragmaMetaBody mb
 

Definition at line 291 of file wsstree.c.

References WsPragmaMetaBodyRec::content, WsPragmaMetaBodyRec::property_name, WsPragmaMetaBodyRec::scheme, ws_free(), ws_lexer_free_utf8(), WsCompilerPtr, and WsPragmaMetaBody.

Referenced by yyparse().

00292 {
00293     if (mb == NULL)
00294         return;
00295 
00296     ws_lexer_free_utf8(compiler, mb->property_name);
00297     ws_lexer_free_utf8(compiler, mb->content);
00298     ws_lexer_free_utf8(compiler, mb->scheme);
00299 
00300     ws_free(mb);
00301 }

Here is the call graph for this function:

void ws_pragma_use WsCompilerPtr  compiler,
WsUInt32  line,
char *  identifier,
WsUtf8String url
 

Definition at line 220 of file wsstree.c.

References WsCompilerRec::bc, WsUtf8StringRec::data, error(), WsUtf8StringRec::len, WsPragmaUseRec::line, WsCompilerRec::pragma_use_hash, ws_bc_add_const_utf8_string(), ws_calloc(), ws_error_memory(), ws_free(), ws_hash_get(), ws_hash_put(), ws_lexer_free_block(), ws_lexer_free_utf8(), ws_src_error(), WsCompilerPtr, WsPragmaUse, and WsUtf8String.

Referenced by yyparse().

00222 {
00223     WsPragmaUse *u = ws_calloc(1, sizeof(*u));
00224     WsPragmaUse *uold;
00225 
00226     /* Do we already know this pragma? */
00227     uold = ws_hash_get(compiler->pragma_use_hash, identifier);
00228     if (uold) {
00229         ws_src_error(compiler, line, "redefinition of pragma `%s'", identifier);
00230         ws_src_error(compiler, uold->line, "`%s' previously defined here",
00231                      identifier);
00232         goto error_cleanup;
00233     }
00234 
00235     if (u == NULL)
00236         goto error;
00237 
00238     u->line = line;
00239 
00240     /* Insert the URL to the byte-code module. */
00241     if (!ws_bc_add_const_utf8_string(compiler->bc, &u->urlindex, url->data,
00242                                      url->len))
00243         goto error;
00244 
00245     /* Add it to the use pragma hash. */
00246     if (!ws_hash_put(compiler->pragma_use_hash, identifier, u))
00247         goto error;
00248 
00249     /* Cleanup. */
00250 
00251     ws_lexer_free_block(compiler, identifier);
00252     ws_lexer_free_utf8(compiler, url);
00253 
00254     return;
00255 
00256     /* Error handling. */
00257 
00258 error:
00259 
00260     ws_error_memory(compiler);
00261 
00262 error_cleanup:
00263 
00264     ws_free(u);
00265     ws_lexer_free_block(compiler, identifier);
00266     ws_lexer_free_utf8(compiler, url);
00267 }

Here is the call graph for this function:

WsHashPtr ws_pragma_use_hash_create void   ) 
 

Definition at line 214 of file wsstree.c.

References pragma_use_hash_destructor(), ws_hash_create(), and WsHashPtr.

Referenced by compile_stream().

00215 {
00216     return ws_hash_create(pragma_use_hash_destructor, NULL);
00217 }

Here is the call graph for this function:

WsStatement* ws_stmt_block WsCompilerPtr  compiler,
WsUInt32  first_line,
WsUInt32  last_line,
WsList block
 

Referenced by yyparse().

WsStatement* ws_stmt_break WsCompilerPtr  compiler,
WsUInt32  line
 

Referenced by yyparse().

WsStatement* ws_stmt_continue WsCompilerPtr  compiler,
WsUInt32  line
 

Referenced by yyparse().

WsStatement* ws_stmt_empty WsCompilerPtr  compiler,
WsUInt32  line
 

Referenced by yyparse().

WsStatement* ws_stmt_expr WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression expr
 

Referenced by yyparse().

WsStatement* ws_stmt_for WsCompilerPtr  compiler,
WsUInt32  line,
WsList init,
WsExpression e1,
WsExpression e2,
WsExpression e3,
WsStatement stmt
 

Definition at line 1447 of file wsstree.c.

References WsStatementRec::e1, WsStatementRec::e2, WsStatementRec::e3, WsStatementRec::init, WsStatementRec::s_for, WsStatementRec::stmt, stmt_alloc(), WsStatementRec::u, WS_STMT_FOR, WsCompilerPtr, WsExpression, WsList, and WsStatement.

Referenced by yyparse().

01450 {
01451     WsStatement *stmt = stmt_alloc(compiler, WS_STMT_FOR, line, line);
01452 
01453     if (stmt) {
01454         stmt->u.s_for.init = init;
01455         stmt->u.s_for.e1 = e1;
01456         stmt->u.s_for.e2 = e2;
01457         stmt->u.s_for.e3 = e3;
01458         stmt->u.s_for.stmt = stmt_body;
01459     }
01460 
01461     return stmt;
01462 }

Here is the call graph for this function:

WsStatement* ws_stmt_if WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression expr,
WsStatement s_then,
WsStatement s_else
 

Referenced by yyparse().

void ws_stmt_linearize WsCompilerPtr  compiler,
WsStatement stmt
 

Referenced by compile_stream(), and ws_stmt_linearize().

WsStatement* ws_stmt_return WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression expr
 

Definition at line 1491 of file wsstree.c.

References WsStatementRec::expr, stmt_alloc(), WsStatementRec::u, WS_STMT_RETURN, WsCompilerPtr, WsExpression, and WsStatement.

Referenced by yyparse().

01493 {
01494     WsStatement *stmt = stmt_alloc(compiler, WS_STMT_RETURN, line, line);
01495 
01496     if (stmt)
01497         stmt->u.expr = expr;
01498 
01499     return stmt;
01500 }

Here is the call graph for this function:

WsStatement* ws_stmt_variable WsCompilerPtr  compiler,
WsUInt32  line,
WsList variables
 

Definition at line 1401 of file wsstree.c.

References stmt_alloc(), WsStatementRec::u, WsStatementRec::var, WS_STMT_VARIABLE, WsCompilerPtr, WsList, and WsStatement.

Referenced by yyparse().

01403 {
01404     WsStatement *stmt = stmt_alloc(compiler, WS_STMT_VARIABLE, line, line);
01405 
01406     if (stmt)
01407         stmt->u.var = variables;
01408 
01409     return stmt;
01410 }

Here is the call graph for this function:

WsStatement* ws_stmt_while WsCompilerPtr  compiler,
WsUInt32  line,
WsExpression expr,
WsStatement stmt
 

Referenced by yyparse().

WsVarDec* ws_variable_declaration WsCompilerPtr  compiler,
char *  name,
WsExpression expr
 

Definition at line 78 of file wsstree.c.

References WsVarDecRec::expr, WsVarDecRec::name, WsCompilerRec::pool_stree, ws_error_memory(), ws_f_malloc(), WsCompilerPtr, WsExpression, and WsVarDec.

Referenced by yyparse().

00080 {
00081     WsVarDec *vardec = ws_f_malloc(compiler->pool_stree, sizeof(*vardec));
00082 
00083     if (vardec == NULL)
00084         ws_error_memory(compiler);
00085     else {
00086         vardec->name = name;
00087         vardec->expr = expr;
00088     }
00089 
00090     return vardec;
00091 }

Here is the call graph for this function:

WsNamespace* ws_variable_define WsCompilerPtr  compiler,
WsUInt32  line,
WsBool  variablep,
char *  name
 

Definition at line 160 of file wsstree.c.

References WsNamespaceRec::line, name, WsCompilerRec::next_vindex, WsCompilerRec::variables_hash, WsNamespaceRec::vindex, ws_calloc(), ws_error_memory(), ws_free(), ws_hash_get(), ws_hash_put(), ws_src_error(), WsCompilerPtr, and WsNamespace.

Referenced by compile_stream(), and linearize_variable_init().

00162 {
00163     WsNamespace *ns;
00164 
00165     /* Is the symbol already defined? */
00166     ns = ws_hash_get(compiler->variables_hash, name);
00167     if (ns) {
00168         ws_src_error(compiler, line, "redeclaration of `%s'", name);
00169         ws_src_error(compiler, ns->line, "`%s' previously declared here", name);
00170         return NULL;
00171     }
00172 
00173     /* Can we still define more variables? */
00174     if (compiler->next_vindex > 255) {
00175         /* No we can't. */
00176         ws_src_error(compiler, line, "too many local variables");
00177         return NULL;
00178     }
00179 
00180     ns = ws_calloc(1, sizeof(*ns));
00181     if (ns == NULL) {
00182         ws_error_memory(compiler);
00183         return NULL;
00184     }
00185 
00186     ns->line = line;
00187     ns->vindex = compiler->next_vindex++;
00188 
00189     if (!ws_hash_put(compiler->variables_hash, name, ns)) {
00190         ws_free(ns);
00191         ws_error_memory(compiler);
00192         return NULL;
00193     }
00194 
00195     return ns;
00196 }

Here is the call graph for this function:

WsHashPtr ws_variable_hash_create void   ) 
 

Definition at line 154 of file wsstree.c.

References variable_hash_destructor(), ws_hash_create(), and WsHashPtr.

Referenced by compile_stream().

00155 {
00156     return ws_hash_create(variable_hash_destructor, NULL);
00157 }

Here is the call graph for this function:

WsNamespace* ws_variable_lookup WsCompilerPtr  compiler,
char *  name
 

Definition at line 199 of file wsstree.c.

References name, WsCompilerRec::variables_hash, ws_hash_get(), WsCompilerPtr, and WsNamespace.

Referenced by ws_expr_linearize().

00200 {
00201     return ws_hash_get(compiler->variables_hash, name);
00202 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.