コード例 #1
0
ファイル: api.c プロジェクト: axcoto-lab/Sparkling
void spn_value_release(const SpnValue *val)
{
	if (isobject(val)) {
		assert(isstring(val) || isarray(val)
		   || ishashmap(val) || isfunc(val)
		   || isuserinfo(val));

		spn_object_release(objvalue(val));
	}
}
コード例 #2
0
ファイル: func.c プロジェクト: haccks/Sparkling
static void free_func(void *obj)
{
	SpnFunction *func = obj;

	/* if the function represents a top-level program,
	 * the free the array containing the local symbol table
	 */
	if (func->topprg) {
		free(func->repr.bc);
		spn_object_release(func->symtab);
	}

	/* if the function is a closure,
	 * then free the array of upvalues
	 */
	if (func->is_closure) {
		assert(func->upvalues);
		spn_object_release(func->upvalues);
	}
}
コード例 #3
0
ファイル: ast.c プロジェクト: CodaFi/Sparkling
void spn_ast_free(SpnAST *ast)
{
	if (ast == NULL) {
		return;
	}

	spn_value_release(&ast->value);

	if (ast->name != NULL) {
		spn_object_release(ast->name);
	}

	spn_ast_free(ast->left);
	spn_ast_free(ast->right);

	free(ast);
}