public void Store(IStorableLiteral var, Expression val) { if (var.StoreMode != EStoreMode.Transfer) { throw new NotSupportedException(); } _isTarget = true; var.Accept(this); var rhs = val as LiteralReference; if (rhs == null) { throw new NotSupportedException(); } _isTarget = false; rhs.ReferencedObject.Accept(this); }
public InlineFieldMapperTransactionSite(InlineFieldMapper mapper, Component host, IStorableLiteral literal) : base(host) { _mapper = mapper; _literal = literal; }
/// <summary> /// Creates an instruction which stores its operand to a variable /// </summary> public XILInstr StoreVar(IStorableLiteral v) { return(new XILInstr(InstructionCodes.StoreVar, v)); }
/// <summary> /// Declares a literal as output argument. /// </summary> /// <param name="var">literal to declare as output argument</param> protected void DeclareOutput(IStorableLiteral var) { ResultFunction.OutputVariables.Add(var); }
public virtual void DeclareLocal(IStorableLiteral var) { Contract.Assume(_cstack.Count > 0); _cstack.Peek().Locals.Add(var); ResultFunction.LocalVariables.Add(var); }
public virtual void Store(IStorableLiteral var, Expression val) { if (var == null || val == null) throw new ArgumentException(); StoreStatement stmt = new StoreStatement() { Container = var, Value = val }; _cstack.Peek().Statements.Add(stmt); }
public void Store(IStorableLiteral var, Expression val) { Contract.Requires(var != null); Contract.Requires(val != null); }
public void DeclareLocal(IStorableLiteral v) { Contract.Requires(v != null); }
private bool TryInline(ICallable callable, Expression[] args, out IStorableLiteral retv) { FunctionSpec fspec = callable as FunctionSpec; retv = null; if (fspec != null) { // Do not inline intrinsic functions if (fspec.IntrinsicRep != null) return false; var md = fspec.SpecialSysDOMRep; if (md != null) { var fun = md.Implementation; InlineVerifier.CheckAllLocalsDeclared(fun); // Recursion? if (_funStack.Contains(fun)) return false; if (fun.OutputVariables.Count == 0) { if (!fspec.ResultType.CILType.Equals(typeof(void))) { string name = _sim.GetUniqueName("$ret", new object()); IStorableLiteral rv = new Variable(fspec.ResultType) { Name = name }; retv = _locals[Tuple.Create(fun, rv)]; } } else if (fun.OutputVariables.Count == 1) { retv = _locals[Tuple.Create(fun, fun.OutputVariables[0])]; } else { throw new NotSupportedException(); } // account for possible "this" argument int j = args.Length - fun.InputVariables.Count; for (int i = j; i < args.Length; i++) { Expression rhs = args[i].Transform(this); var lhs = _locals[Tuple.Create(fun, fun.InputVariables[i - j])]; Store(lhs, rhs); } if (retv != null) _retStack.Push(retv); _funStack.Push(fun); _getOutStack.Push(new List<GotoStatement>()); fun.Body.Accept(this); _funStack.Pop(); if (retv != null) _retStack.Pop(); Nop(); foreach (var getOut in _getOutStack.Pop()) { getOut.Target = LastStatement; } _inlinedFunctions.Add(fun); return true; } else { //System.Diagnostics.Debug.Assert(false, "function not decompiled - bug?"); } } return false; }
private bool TryInline(ICallable callable, Expression[] args, out IStorableLiteral retv) { FunctionSpec fspec = callable as FunctionSpec; retv = null; if (fspec != null) { // Do not inline intrinsic functions if (fspec.IntrinsicRep != null) { return(false); } var md = fspec.SpecialSysDOMRep; if (md != null) { var fun = md.Implementation; InlineVerifier.CheckAllLocalsDeclared(fun); // Recursion? if (_funStack.Contains(fun)) { return(false); } if (fun.OutputVariables.Count == 0) { if (!fspec.ResultType.CILType.Equals(typeof(void))) { string name = _sim.GetUniqueName("$ret", new object()); IStorableLiteral rv = new Variable(fspec.ResultType) { Name = name }; retv = _locals[Tuple.Create(fun, rv)]; } } else if (fun.OutputVariables.Count == 1) { retv = _locals[Tuple.Create(fun, fun.OutputVariables[0])]; } else { throw new NotSupportedException(); } // account for possible "this" argument int j = args.Length - fun.InputVariables.Count; for (int i = j; i < args.Length; i++) { Expression rhs = args[i].Transform(this); var lhs = _locals[Tuple.Create(fun, fun.InputVariables[i - j])]; Store(lhs, rhs); } if (retv != null) { _retStack.Push(retv); } _funStack.Push(fun); _getOutStack.Push(new List <GotoStatement>()); fun.Body.Accept(this); _funStack.Pop(); if (retv != null) { _retStack.Pop(); } Nop(); foreach (var getOut in _getOutStack.Pop()) { getOut.Target = LastStatement; } _inlinedFunctions.Add(fun); return(true); } else { //System.Diagnostics.Debug.Assert(false, "function not decompiled - bug?"); } } return(false); }
public void DeclareLocal(IStorableLiteral v) { }