/// <summary> /// Converts the return value into a call to Contract.Result /// </summary> public override IExpression Rewrite(IReturnValue returnValue) { var mref = contractProvider.ContractMethods.Result; var methodToCall = new GenericMethodInstanceReference { CallingConvention = CallingConvention.Generic, ContainingType = mref.ContainingType, GenericArguments = new List <ITypeReference> { returnValue.Type }, GenericMethod = mref, InternFactory = host.InternFactory, Name = mref.Name, Type = returnValue.Type }; var methodCall = new MethodCall { IsStaticCall = true, MethodToCall = methodToCall, Type = returnValue.Type, Locations = new List <ILocation>(returnValue.Locations) }; return(methodCall); }
public override void Visit(IReturnValue returnValue) { if (Process(returnValue)) { visitor.Visit(returnValue); } base.Visit(returnValue); }
private static TokenBinaryExpression BuildExpression(char opt, IReturnValue left, IReturnValue right) { return new TokenBinaryExpression() { Left = left, Operator = opt, Right = right }; }
public override String ToString() { IEnumerator itr = Iterator; StringBuilder sb = new StringBuilder(); while (itr.MoveNext()) { IReturnValue rval = (IReturnValue)itr.Current; sb.Append(rval.StringValue).Append('\n'); } return(sb.ToString()); }
/// <summary> The method uses the function to evaluate the fact /// </summary> /// <param name="">factInstance /// </param> /// <returns> /// /// </returns> public virtual bool evaluate(IFact factInstance, Rete engine) { for (int idx = 0; idx < params_Renamed.Length; idx++) { if (params_Renamed[idx] is BoundParam) { ((BoundParam)params_Renamed[idx]).Facts = new IFact[] { factInstance }; } } IReturnVector rv = function.executeFunction(engine, params_Renamed); IReturnValue rval = rv.firstReturnValue(); return(rval.BooleanValue); }
private void Init(string fileName) { _FileName = fileName; var t = Directory.GetCurrentDirectory(); if (!File.Exists(fileName)) { throw new System.Exception("FILE_NAME_FROM_GRAPH_READER_STORE_IS_INVALID"); } ReturnValue = new CSV_Return_Value { FileValues = new Dictionary <string, List <string> >(), FileLocation = fileName, Headers = new string[0] }; }
protected void parse(Rete engine, CLIPSParser parser, IList factlist) { Object itm = null; try { while ((itm = parser.basicExpr()) != null) { // System.Console.WriteLine("obj is " + itm.getClass().Name); if (itm is Defrule) { Defrule rule = (Defrule)itm; engine.RuleCompiler.addRule(rule); } else if (itm is Deftemplate) { Deftemplate dt = (Deftemplate)itm; Console.WriteLine("template=" + dt.Name); engine.declareTemplate(dt); } else if (itm is FunctionAction) { FunctionAction fa = (FunctionAction)itm; } else if (itm is IFunction) { IReturnVector rv = ((IFunction)itm).executeFunction(engine, null); IEnumerator itr = rv.Iterator; while (itr.MoveNext()) { IReturnValue rval = (IReturnValue)itr.Current; Console.WriteLine(rval.StringValue); } } } } catch { // Console.WriteLine(e.Message); parser.ReInit(Console.OpenStandardInput()); } }
/// <summary> /// 计算带返回值的语句或表达式 /// </summary> /// <param name="value"></param> /// <returns></returns> private ScriptValue ReturnValue(IReturnValue value) { switch (value) { case TokenLiteral literal: return(new ScriptValue { DataType = literal.DataType, Value = literal.Value }); case TokenVariableRef varRef: return(_stack.Get(varRef.Variable)); case TokenJudgmentExpression expr: return(Judgment(expr)); case TokenBinaryExpression binExpr: return(SumBinaryExpression(binExpr)); case TokenFunctionCallStement call: return(ExcuteCall(call)); } throw new Exception("不支持的取值方式."); }
public void Visit(IReturnValue returnValue) { this.result = this.rewriter.Rewrite(returnValue); }
public virtual void onASTElement(IReturnValue returnValue) { }
public override void TraverseChildren(IReturnValue returnValue) { //this.sourceEmitterOutput.Write("result"); this.sourceEmitterOutput.Write("Contract.Result<"); this.PrintTypeReference(returnValue.Type); this.sourceEmitterOutput.Write(">()"); }
/// <summary> /// /// </summary> /// <param name="returnValue"></param> public ReturnValue(IReturnValue returnValue) : base(returnValue) { }
public virtual void addReturnValue(IReturnValue val) { items.Add(val); }
/// <summary> /// Returns a shallow copy of the given return value expression. /// </summary> /// <param name="returnValue"></param> public ReturnValue Copy(IReturnValue returnValue) { return new ReturnValue(returnValue); }
/// <summary> /// Performs some computation with the given return value expression. /// </summary> /// <param name="returnValue"></param> public virtual void Visit(IReturnValue returnValue) { }
public override void Visit(IReturnValue returnValue) { allElements.Add(new InvokInfo(Traverser, "IReturnValue", returnValue)); }
public override void TraverseChildren(IReturnValue returnValue) { base.TraverseChildren(returnValue); ((ReturnValue)returnValue).Type = this.containingType; }
/// <summary> /// Converts the return value into a call to Contract.Result /// </summary> public override IExpression Rewrite(IReturnValue returnValue) { var mref = this.contractProvider.ContractMethods.Result; var methodToCall = new Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference() { CallingConvention = CallingConvention.Generic, ContainingType = mref.ContainingType, GenericArguments = new List<ITypeReference> { returnValue.Type }, GenericMethod = mref, InternFactory = this.host.InternFactory, Name = mref.Name, Type = returnValue.Type, }; var methodCall = new MethodCall() { IsStaticCall = true, MethodToCall = methodToCall, Type = returnValue.Type, Locations = new List<ILocation>(returnValue.Locations), }; return methodCall; }
/// <summary> /// Throws an exception when executed: IReturnValue nodes /// must be replaced before converting the Code Model to IL. /// </summary> public override void TraverseChildren(IReturnValue returnValue) { Contract.Assume(false, "IReturnValue nodes must be replaced before trying to convert the Code Model to IL."); }
public void MergeMessages(IReturnValue retVal) { if (retVal != null) { if ((retVal.Succeeded) && (retVal.HasWarning)) AdditionalMessages.Add(new UIMessage(retVal.Message, UIMessage.MessageTypes.Warning)); else if (retVal.Succeeded) AdditionalMessages.Add(new UIMessage(retVal.Message, UIMessage.MessageTypes.General)); else AdditionalMessages.Add(new UIMessage(retVal.Message, UIMessage.MessageTypes.Error)); foreach (UIMessage msg in retVal.AdditionalMessages) AdditionalMessages.Add(msg); } }
/// <summary> /// Visits the specified return value. /// </summary> /// <param name="returnValue">The return value.</param> public override void Visit(IReturnValue returnValue) { ReturnValue mutableReturnValue = new ReturnValue(returnValue); this.resultExpression = this.myCodeCopier.DeepCopy(mutableReturnValue); }
/// <summary> /// Traverses the children of the return value expression. /// </summary> public virtual void TraverseChildren(IReturnValue returnValue) { Contract.Requires(returnValue != null); this.TraverseChildren((IExpression)returnValue); }
/// <summary> /// Returns a deep copy of the given return value expression. /// </summary> /// <param name="returnValue"></param> public ReturnValue Copy(IReturnValue returnValue) { var mutableCopy = this.shallowCopier.Copy(returnValue); this.CopyChildren((Expression)mutableCopy); return mutableCopy; }
/// <summary> /// Performs some computation with the given return value expression. /// </summary> /// <param name="returnValue"></param> public virtual void Visit(IReturnValue returnValue) { this.Visit((IExpression)returnValue); }
public void Visit(IReturnValue returnValue) { this.result = this.copier.Copy(returnValue); }
public void Visit(IReturnValue returnValue) { throw new NotImplementedException(); }
public override void TraverseChildren(IReturnValue returnValue) { MethodEnter(returnValue); base.TraverseChildren(returnValue); MethodExit(); }
public override void Visit(IReturnValue returnValue) { if(Process(returnValue)){visitor.Visit(returnValue);} base.Visit(returnValue); }
/// <summary> /// Traverses the return value expression. /// </summary> public void Traverse(IReturnValue returnValue) { Contract.Requires(returnValue != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(returnValue); if (this.StopTraversal) return; this.TraverseChildren(returnValue); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(returnValue); }
/// <summary> /// Rewrites the given return value expression. /// </summary> /// <param name="returnValue"></param> public virtual IExpression Rewrite(IReturnValue returnValue) { return returnValue; }
public void Visit(IReturnValue returnValue) { this.traverser.Traverse(returnValue); }
public void Visit(IReturnValue returnValue) { Contract.Requires(returnValue != null); throw new NotImplementedException(); }
/// <summary> /// Returns a shallow copy of the given return value expression. /// </summary> /// <param name="returnValue"></param> public ReturnValue Copy(IReturnValue returnValue) { Contract.Requires(returnValue != null); Contract.Ensures(Contract.Result<ReturnValue>() != null); return new ReturnValue(returnValue); }
public override void Visit(IReturnValue returnValue) { if (this.sink.RetVariable == null) { throw new TranslationException(String.Format("Don't know what to do with return value {0}", returnValue.ToString())); } TranslatedExpressions.Push(new Bpl.IdentifierExpr(returnValue.Token(), this.sink.RetVariable)); }
/// <summary> /// Returns a deep copy of the given return value expression. /// </summary> /// <param name="returnValue"></param> public ReturnValue Copy(IReturnValue returnValue) { Contract.Requires(returnValue != null); Contract.Ensures(Contract.Result<ReturnValue>() != null); var mutableCopy = this.shallowCopier.Copy(returnValue); this.CopyChildren((Expression)mutableCopy); return mutableCopy; }
public override void TraverseChildren(IReturnValue returnValue) { base.sourceEmitterOutput.Write("result"); }
/// <summary> /// Visits the specified return value. /// </summary> /// <param name="returnValue">The return value.</param> public override void Visit(IReturnValue returnValue) { ReturnValue mutableReturnValue = returnValue as ReturnValue; if (alwaysMakeACopy || mutableReturnValue == null) mutableReturnValue = new ReturnValue(returnValue); this.resultExpression = this.myCodeMutator.Visit(mutableReturnValue); }
private static TokenJudgmentExpression BuildTokenJudgmentExpression(JudgmentExpressionType opt, IReturnValue left, IReturnValue right) { return new TokenJudgmentExpression() { Left = left, Operator = opt, Right = right }; }
/// <summary> /// Rewrites the given return value expression. /// </summary> /// <param name="returnValue"></param> public virtual IExpression Rewrite(IReturnValue returnValue) { var mutableReturnValue = returnValue as ReturnValue; if (mutableReturnValue == null) return returnValue; this.RewriteChildren(mutableReturnValue); return mutableReturnValue; }
/// <summary> /// Visits the specified return value. /// </summary> /// <param name="returnValue">The return value.</param> public override void Visit(IReturnValue returnValue) { ReturnValue mutableReturnValue = returnValue as ReturnValue; if (mutableReturnValue == null) { this.resultExpression = returnValue; return; } this.resultExpression = this.myCodeMutator.Visit(mutableReturnValue); }