public override Expression.EvalResult Execute(MakeState s) { Expression.EvalResult e = new Expression.EvalResult(val); s.SetDefine(tok_name, e, assignop); if (export) { ExportDef(tok_name, s); } return(new Expression.EvalResult(0)); }
internal static void ExportDef(string tag, MakeState s) { Expression.EvalResult e = s.GetDefine(tag); MakeState cur_s = s.parent; while (cur_s != null) { cur_s.SetDefine(tag, e); cur_s = cur_s.parent; } }
public override Expression.EvalResult Execute(MakeState s) { var f = include_file.Evaluate(s).strval; var saved_this = s.GetDefine("THIS"); MakeState new_s = s.Clone(); var ret = TymakeLib.ExecuteFile(f, new_s); s.SetDefine("THIS", saved_this, true); return(ret); }
public override Expression.EvalResult Execute(MakeState s) { LabelExpression le = new LabelExpression { val = val }; Expression.EvalResult e = le.Evaluate(s); s.SetDefine(tok_name, e, assignop); if (export) { ExportDef(tok_name, s); } return(new Expression.EvalResult(0)); }
public void SetDefine(string tag, Expression.EvalResult e, bool export) { if (export == false) { SetLocalDefine(tag, e); } else { MakeState s = this; while (s != null) { s.SetDefine(tag, e); s = s.parent; } } }
public override Expression.EvalResult Execute(MakeState s) { if (s.IsDefined(v) == false) { throw new Exception("export: variable " + v + " is not defined in this scope"); } Expression.EvalResult e = s.GetDefine(v); s.SetDefine(v, e); MakeState cur_s = s.parent; while (cur_s != null) { cur_s.SetDefine(v, e); cur_s = cur_s.parent; } return(new Expression.EvalResult(0)); }
public override Expression.EvalResult Execute(MakeState s) { // if this is a conditional assign, we don't need to evaluate the RHS // if the LHS is already assigned if (assignop == Tokens.ASSIGNIF & tok_name is LabelExpression) { var tn = ((LabelExpression)tok_name).val; if (s.IsDefined(tn)) { return(new Expression.EvalResult(0)); } } Expression.EvalResult e = val.Evaluate(s); if (tok_name is LabelExpression) { var tn = ((LabelExpression)tok_name).val; s.SetDefine(tn, e, assignop); if (export) { ExportDef(tn, s); } } else if (tok_name is LabelMemberExpression) { // left-most member must be a define var lme = tok_name as LabelMemberExpression; if (!(lme.label is LabelExpression)) { throw new Exception("unable to assign to " + tok_name.ToString()); } var o = s.GetDefine(((LabelExpression)lme.label).val); // Now iterate through the various members, looking for // what to set Expression cur_member_lval = lme.member; while (true) { if (cur_member_lval is LabelExpression) { // we've reached the end of the chain break; } else if (cur_member_lval is LabelMemberExpression) { var new_lme = cur_member_lval as LabelMemberExpression; if (!(new_lme.label is LabelExpression)) { throw new Exception("unable to assign to " + tok_name.ToString()); } lme = new_lme; cur_member_lval = lme.member; if (o.Type != Expression.EvalResult.ResultType.Object) { throw new Exception(); } o = o.objval[((LabelExpression)lme.label).val]; } else { throw new NotImplementedException(); } } string member_name = ((LabelExpression)cur_member_lval).val; o.objval[member_name] = e; } else if (tok_name is LabelIndexedExpression) { var chain = get_chain(tok_name); // left-most member must be a define var lme = chain[0]; if (!(lme is LabelExpression)) { throw new Exception("unable to assign to " + tok_name.ToString()); } var o = s.GetDefine(((LabelExpression)lme).val); // Now iterate through the various members, looking for // what to set o = follow_chain(o, chain, 1, chain.Count - 1, s); if (o.Type != Expression.EvalResult.ResultType.Array) { throw new Exception("unable to assign to " + tok_name.ToString()); } var idx = ((LabelIndexedExpression)tok_name).index.Evaluate(s).AsInt; // increase the array size as appropriate if (idx >= o.arrval.Count) { o.arrval.Capacity = (int)idx * 3 / 2; while (idx >= o.arrval.Count) { o.arrval.Add(new Expression.EvalResult { Type = Expression.EvalResult.ResultType.Null }); } } o.arrval[(int)idx] = e; } else { throw new NotImplementedException(); } return(new Expression.EvalResult(0)); }