///****************************************************************************
// * 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
//
///* ------------------------------------------------------------------------ */
//
//INLINE
//knh_asmv_t 
//new_asmv(knh_uchar_t potype, knh_uchar_t idx, knh_type_t type, Object *value)
//{
//	knh_asmv_t v = {potype, idx, type, value};
//	return v;
//}
//
//#define _new_asmv__EBP(n,type)     new_asmv(KNH_ASMV_EBP, n, type, NULL)
//#define _new_asmv__SFP(n,type)     new_asmv(KNH_ASMV_SFP, n, type, NULL)
//#define _new_asmv__OFP(n,type)     new_asmv(KNH_ASMV_OFP, n, type, NULL)
//#define _new_asmv__OIDX(o,n,type)  new_asmv(KNH_ASMV_OIDX, n, type, o)
//#define _new_asmv__ONSTACK(type)   new_asmv(KNH_ASMV_ONSTACK, 0, type, NULL)
//
///* ------------------------------------------------------------------------ */
//
//knh_asmv_t
//new_asmv__OBJ(Object *v)
//{
//	return new_asmv(KNH_ASMV_OBJ, 0, knh_Object_cid(v), v);	
//}
//
/////* ------------------------------------------------------------------------ */
////
////knh_asmv_t
////new_asmv__StaticValue(Ctx *ctx, Token *tk, knh_type_t req)
////{
////	knh_class_t cid = knh_Object_cid(tk->data);
//////	if(cid != TYPE_TONOTNULL(req)) {
//////		TODO();
//////		DEBUG("need map from cid=%s, req=%s%s", CLASSN(cid), TYPEQN(req));
//////	}
////	return new_asmv(KNH_ASMV_OBJ, 0, cid, tk->data);	
////}
////
//
////
////
/////* ------------------------------------------------------------------------ */
/////* [ASM_CALL] */
////
////
////
/////* ------------------------------------------------------------------------ */
////
//
/////* ------------------------------------------------------------------------ */
////
////knh_asmv_t
////knh_Compiler_asmv__call(Ctx *ctx, Compiler *b, Stmt *stmt, knh_type_t req, knh_bool_t isfirst)
////{
////	KNH_ASSERT(IS_Token(stmt->terms[0]));
////	Token *tke = (Token*)stmt->terms[0];
////
////	if(stmt->size == 1) {
////		knh_Stmt_setVisible(stmt, 1);
////		knh_Stmt_terms_seval(ctx, stmt, 0, CLASS_any, knh_Compiler_getNameSpace(ctx, b));
////		knh_asmv_t asmv = knh_Compiler_asmv(ctx, b, stmt->terms[0], req, isfirst);
////		KNH_ASM_PPUSH(ctx, b, asmv, isfirst);
////		return new_asmv__ONSTACK(asmv.type);
////	}
////	
////	knh_methodn_t mn = knh_Token_tomethodn(ctx, tke);
////	KNH_ASM_PUSH__mn(ctx, b, mn, isfirst);
////	knh_bool_t isautomap = knh_Token_isTailC(tke);
////	
////	Token *tk_ = (Token*)stmt->terms[1]; 
////	if(IS_Token(tk_) && tk_->tt == TT_ASIS) {
////		DEBUG("find function.. %s", knh_Token_tochar(tke));
////		DEBUG("fn=%d, size=%d", b->vars[0].fn, b->vars_size);
////		KNH_ASSERT(b->vars[0].fn == FIELDN_this);
////		knh_class_t _cid = TYPE_TONOTNULL(b->vars[0].type);
////		Method *_mtd = knh_Class_getMethod(ctx, _cid, mn);
////		if(IS_NOTNULL(_mtd)) {
////			KNH_SETv(ctx, stmt->terms[1], new_Token__text(ctx, tk_, STEXT("this")));
////			goto L_SELF;
////		}
////		if(_cid != knh_Object_cid(b->nsproto)) {
////			_cid = knh_Object_cid(b->nsproto);
////			_mtd = knh_Class_getMethod(ctx, _cid, mn);
////			if(IS_NOTNULL(_mtd)) {
////				KNH_SETv(ctx, stmt->terms[1], new_Token__text(ctx, tk_, STEXT("__")));
////				goto L_SELF;
////			}
////		}
////		Class *c_ = knh_NameSpace_getFuncClass(ctx, knh_Compiler_getNameSpace(ctx, b), knh_Token_tobytes(tke));
////		if(IS_NOTNULL(c_)) {
////			knh_Token_setCONST(ctx, tk_, c_);
////		}
////		else {
////			KNH_SETv(ctx, stmt->terms[1], new_Token__text(ctx, tk_, STEXT("this")));
////		}
////	}
////	
////	L_SELF:;	
////	knh_Stmt_terms_seval(ctx, stmt, 1, CLASS_any, knh_Compiler_getNameSpace(ctx, b));
////	knh_asmv_t self = knh_Compiler_asmv(ctx, b, stmt->terms[1], TYPE_any, 0);
////	if(self.potype == KNH_ASMV_OBJ && IS_Class(self.value)) {
////		KNH_ASM_PUSH__DEF(ctx, b, knh_Class_cid(self.value));
////		self.type = knh_Class_cid(self.value);
////	} else {
////		KNH_ASM_PPUSH(ctx, b, self, 0); 
////	}
////
////	/* CHECK_PARAMS */
////	Method *mtd = NULL;
////	if(self.type == CLASS_any || self.type == TYPE_any) {
////		mtd = KNH_NULL;
////	}
////	else {
////		mtd = knh_Class_getMethod(ctx, knh_type_toclass(self.type), mn);
////	}
////	int c = KNH_ASM_PUSH_PARAMS(ctx, b, tke, stmt, self.type, mtd, isautomap);
////
////	if(IS_Method(mtd) && !knh_Method_isNoSuchMethod(mtd)) {
////		if(knh_Method_rtype(mtd) != TYPE_void) {
////			knh_Stmt_setVisible(stmt, 1);
////		}
////		KNH_ASM_CALL_METHOD(ctx, b, mtd, self.type, c);
////		return new_asmv__ONSTACK(knh_Method_rtype(mtd));
////	}
////	else {
////		DEBUG("dynamic call");
////		if(METHODN_IS_GETTER(mn)) {
////			knh_Stmt_setVisible(stmt, 1);
////		}
////		KNH_ASM_DCALL_METHOD(ctx, b, isautomap, c);
////		return new_asmv__ONSTACK(TYPE_any);
////	}
////}
////
////
/////* ------------------------------------------------------------------------ */
////
////knh_asmv_t
////knh_Compiler_asmv__next(Ctx *ctx, Compiler *b, Stmt *stmt, knh_type_t req, knh_bool_t isfirst)
////{
////	/* Closure */
////	TODO();
////	return new_asmv__OBJ(KNH_NULL);	
////}
////
/////* ------------------------------------------------------------------------ */
////
////knh_asmv_t
////knh_Compiler_asmv__method(Ctx *ctx, Compiler *b, Stmt *stmt, knh_type_t req, knh_bool_t isfirst)
////{
////	/* Closure */
////	TODO();
////	return new_asmv__OBJ(KNH_NULL);	
////}
//////
/////* ------------------------------------------------------------------------ */
//
//#ifdef __cplusplus
//}
//#endif
