예제 #1
0
// n from beginning to m from end.
func (mt *MtType) EvalExpr(Context *eval.ContextType, n, m int) bool {
	m = len(mt.SVal) - m // Convert to Pos
	sv := mt.SVal[n:m]   // Slice of params to eval.
	fmt.Printf("mt.EvalExpr - TOP: ealuate sv=%+v ----------------------------------------------------- \n", sv)
	fmt.Printf("mt.EvalExpr - TOP: ealuate mt.SVal=%+v ----------------------------------------------------- \n", mt.SVal)
	// xyzzy -- temporary -- incomplete!!!!!!!!!!!!!!!!!!!!!!
	evalData := &eval.EvalType{
		Pos: 0,
		Ctx: Context,
		Mm:  mt.TokVal[n:m], // []tok.Token
	}
	fmt.Printf("INPUT m=%d n=%d, %s ----------------------------------------------------- \n", m, n, com.SVarI(evalData))
	tr := evalData.Pres2()
	fmt.Printf("BOTTOM: %s ----------------------------------------------------- \n", com.SVarI(tr))
	s := sv[0]
	v, t, _ := Context.GetFromContext(s)
	fmt.Printf("At: %s - in EvalExpr, v=%v t=%v for >%s<-\n", com.LF(), v, t, s)
	// xyzzy nil, 9 -- 9 is error, not found
	if t == eval.CtxType_Bool {
		fmt.Printf("Setting bool to true\n")
		mt.DataType = t
		mt.XValue = v
	}
	return true
}
예제 #2
0
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
func FxGet_context(callNo int, pt *Parse2Type, Context *eval.ContextType, curTree *MtType) (err error) {
	fmt.Printf("GetContext Called, %d\n", callNo)
	if callNo == 10 {
		if !curTree.NOptions(1) {
		} else {
			id := curTree.SVal[0] // xyzzy - should be an EvalExpr of ...
			val, typ, fnd := Context.GetFromContext(id)
			if fnd {
				fmt.Printf("Found! id=%s typ=%d = ->%s<-\n", id, typ, val)
				if typ == eval.CtxType_Bool { // xyzzy - other types ...
					if val.(bool) {
						curTree.HTML_Output = "true"
					} else {
						curTree.HTML_Output = "false"
					}
				}
			} else {
				fmt.Printf("Not Found %s\n", id)
				curTree.HTML_Output = ""
			}
		}
	}
	return
}