///****************************************************************************
// * KONOHA COPYRIGHT, LICENSE NOTICE, AND DISCRIMER  
// * 
// * Copyright (c) 2005-2008, Kimio Kuramitsu <kimio at ynu.ac.jp>
// *           (c) 2008-      Konoha Software Foundation  
// * All rights reserved.
// * 
// * You may choose one of the following two licenses when you use konoha. 
// * See www.konohaware.org/license.html for further information.
// * 
// * (1) GNU General Public License 2.0      (with    KONOHA_UNDER_GPL2)
// * (2) Konoha Software Foundation License 1.0
// * 
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 
// * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// *  
// ****************************************************************************/
//
///* ************************************************************************ */
//
//#include"commons.h"
//
///* ************************************************************************ */
//
//#ifdef __cplusplus 
//extern "C" {
//#endif
//
#ifdef KNH_DBGMODE
	#define DEBUG_STMT2(ctx, stmt)
	#define DEBUG_STMT(ctx, stmt) \
		DEBUG("level=%d", level); \
		knh_Stmt__dump(ctx, stmt, KNH_STDOUT, knh_String_EMPTY()); \
		knh_flush(ctx, KNH_STDOUT); \

#else
	#define DEBUG_STMT(ctx, stmt)
#endif
//
///* ------------------------------------------------------------------------ */
///* [asm] */
//
//void knh_stmtvisit_asm__class(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//}
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__method(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//}
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_declv__try(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	/* ['try', '{', '__catch', '{'] */
//
//	if(level > 1) {
//		knh_Stmt_visit(ctx, stmt->terms[1], knh_stmtvisit_declv, v, level+1);
//		TODO();
//		knh_Stmt_visit(ctx, stmt->terms[3], knh_stmtvisit_declv, v, level+1);
//	}
//}
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__try(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	//Compiler *mc = (Compiler*)v;
//	/* ['try', '{', '__catch', '{'] */
//
//	//knh_Stmt_dispatch(ctx, stmt, knh_stmtvisit_asm, v, level, step);
//	//knh_Stmt_done(ctx, stmt);
//}
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__catch(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	//Compiler *mc = (Compiler*)v;
//	/* ['catch', 'EXPTN', 'FIELDN', '{'] */
//
//	//knh_Stmt_dispatch(ctx, stmt, knh_stmtvisit_asm, v, level, step);
//	//knh_Stmt_done(ctx, stmt);
//}
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__throw(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	/* ['throw', 'expr'] */
//	KNH_ASSERT(stmt->size == 2);
//	Compiler *b = (Compiler*)v;
//	Token *tke = (Token*)stmt->terms[0];
//	
//	knh_Stmt_terms_seval(ctx, stmt, 1, CLASS_Exception, knh_Compiler_getNameSpace(ctx, b));
//	knh_asmv_t e = knh_Compiler_asmv(ctx, b, stmt->terms[1], TYPE_Exception, MC_FIRST);
//	knh_class_t cid = TYPE_TONOTNULL(e.type);
//	if(cid != CLASS_Exception && cid != CLASS_String && cid != CLASS_Nue) {
//		MC_EPRINT(ctx, tke, MC_TYPE, "incompatible exception: %s%s", CLASSQN(cid));
//	}
//	KNH_ASM_THROW(ctx, b, e);
//	knh_Stmt_done(ctx, stmt);
//}
//
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__eval(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	//Compiler *b = (Compiler*)v;
//	/* ['eval', 'expr'] */
//
//	//knh_Stmt_dispatch(ctx, stmt, knh_stmtvisit_asm, v, level, step);
//	//knh_Stmt_done(ctx, stmt);
//}
//
///* ------------------------------------------------------------------------ */
//
//
///* ------------------------------------------------------------------------ */
//
//
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__call(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	//Compiler *mc = (Compiler*)v;
//	/* ['METHODN', '+expr'] */
//
//	knh_Compiler_asmv(ctx, (Compiler*)v, stmt, TYPE_any, MC_FIRST);
//	knh_Stmt_done(ctx, stmt);
//}
//
//
//#define _knh_stmtvisit_asm__op           knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__new          knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__map          knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__movtext      knh_stmtvisit_asm__call
//
//#define _knh_stmtvisit_asm__alt          knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__and          knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__or           knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__trinary      knh_stmtvisit_asm__call
//#define _knh_stmtvisit_asm__next         knh_stmtvisit_asm__call
//
///* ------------------------------------------------------------------------ */
//
//void knh_stmtvisit_asm__err(Ctx *ctx, Stmt *stmt, Cmplier *cpr, NameSpace *ns, knh_type_t reqt, int level)
//{
//	//DEBUG_STMT(ctx, stmt);
//	/* ['ERR'] */
//	Compiler *b = (Compiler*)v;
//	
//	Token *tke = (Token*)stmt->terms[0];
//	KNH_ASSERT(IS_Token(tke));
//	DEBUG("SyntaxError!!: %s", knh_Token_tochar(tke));
//		
//	char buf[CLASSNAME_BUFSIZ*2];
//	knh_snprintf(buf, sizeof(buf), "SyntaxError!!:[%s:%d]: %s", FILEN(tke->filen), (int)tke->line, knh_Token_tochar(tke));
//	
//	KNH_ASM_THROW__OBJ(ctx, b, new_Exception__b(ctx, B(buf)));
//	knh_Compiler_setSyntaxError(b, 1);
//	knh_Stmt_done(ctx, stmt);
//}
//
///* ------------------------------------------------------------------------ */
//
//#ifdef __cplusplus
//}
//#endif
