Exemplo n.º 1
0
    void Start()
    {
        // 读取本地题库 -- 测试
        StartCoroutine(LocalInfo.LoadXML());

        Transform RankPK = transform.Find("Body/RankPK");

        if (RankPK != null)
        {
            UIEventListener.Get(RankPK.gameObject).onClick += (go) => SceneManager.LoadScene("RankPK");
        }

        Transform Rank = transform.Find("Body/Rank");

        if (Rank != null)
        {
            UIEventListener.Get(Rank.gameObject).onClick += OnClickRank;
        }

        Transform Shop = transform.Find("Body/Shop");

        if (Shop != null)
        {
            UIEventListener.Get(Shop.gameObject).onClick += (go) => SceneManager.LoadScene("Shop");
        }
    }
Exemplo n.º 2
0
        public void NavOnLoad(params object[] parsObjects)
        {
            isViewActive = true;

            if (parsObjects.Length > 0)
            {
                try
                {
                    if (parsObjects.Count() > 0)
                    {
                        var rtulinfo = parsObjects[0] as Tuple <int, int>;
                        var sluid    = rtulinfo.Item1;
                        var ctrlid   = rtulinfo.Item2;
                        if (Wlst.Sr.EquipmentInfoHolding.Services.EquipmentIdAssignRang.IsSlu(sluid))
                        {
                            SluId = sluid;
                            if (ctrlid > 0)
                            {
                                CtrlId = ctrlid;
                            }
                        }

                        LocalInfo.Clear();
                        Remind = "";
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 3
0
        bool Initialize(List <Block> allBlocks)
        {
            localInfos.Clear();
            foreach (var local in blocks.Locals)
            {
                localInfos[local] = new LocalInfo(local);
            }
            if (localInfos.Count == 0)
            {
                return(false);
            }

            foreach (var block in allBlocks)
            {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count - 1; i++)
                {
                    var ldloc = instrs[i];
                    if (!ldloc.IsLdloc())
                    {
                        continue;
                    }
                    var local = ldloc.Instruction.GetLocal(blocks.Locals);
                    if (local == null)
                    {
                        continue;
                    }
                    var localInfo = localInfos[local];
                    localInfo.CastType = GetCastType(instrs[i + 1]);
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        public AllocationResult RunPass(ControlFlowGraph cfg, StackAllocator stackAlloc, RegisterMasks regMasks)
        {
            int intUsedRegisters = 0;
            int vecUsedRegisters = 0;

            int intFreeRegisters = regMasks.IntAvailableRegisters;
            int vecFreeRegisters = regMasks.VecAvailableRegisters;

            var blockInfo      = new BlockInfo[cfg.Blocks.Count];
            var localInfo      = new LocalInfo[cfg.Blocks.Count * 3];
            int localInfoCount = 0;

            // The "visited" state is stored in the MSB of the local's value.
            const ulong VisitedMask = 1ul << 63;

            bool IsVisited(Operand local)
            {
                return((local.GetValueUnsafe() & VisitedMask) != 0);
            }

            void SetVisited(Operand local)
            {
                local.GetValueUnsafe() |= VisitedMask | (uint)++localInfoCount;
            }

            ref LocalInfo GetLocalInfo(Operand local)
            {
                Debug.Assert(local.Kind == OperandKind.LocalVariable);

                if (!IsVisited(local))
                {
                    throw new InvalidOperationException("Local was not visisted yet. Used before defined?");
                }

                return(ref localInfo[(uint)local.GetValueUnsafe() - 1]);
Exemplo n.º 5
0
        public object EvaluateExpression(string expressionString)
        {
            int    num;
            object obj2;

            if (int.TryParse(expressionString, out num))
            {
                return(num);
            }
            LocalInfo info = null;

            if ((this.cachedLocalInfos != null) && this.cachedLocalInfos.TryGetValue(expressionString, out info))
            {
                return(info);
            }
            LocationReferenceEnvironment publicEnvironment = this.activityInstance.Activity.PublicEnvironment;
            ActivityContext context = new ActivityContext(this.activityInstance, null);

            try
            {
                if (!TryEvaluateExpression(expressionString, null, publicEnvironment, context, out obj2))
                {
                    return(System.Activities.SR.DebugInfoCannotEvaluateExpression(expressionString));
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                context.Dispose();
                return(System.Activities.SR.DebugInfoCannotEvaluateExpression(expressionString));
            }
            try
            {
                object obj3;
                if (TryEvaluateExpression(expressionString, obj2.GetType(), publicEnvironment, context, out obj3))
                {
                    LocalInfo info2 = new LocalInfo {
                        Name     = expressionString,
                        Location = obj3 as System.Activities.Location
                    };
                    this.cachedLocalInfos[expressionString] = info2;
                    return(info2);
                }
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
            }
            finally
            {
                context.Dispose();
            }
            return(obj2);
        }
Exemplo n.º 6
0
        public ExpressionStatement CreateExpressionTreeVariable(BlockContext ec)
        {
            //
            // A parameter is not hoisted when used directly as ET
            //
            HoistedVariableReference = null;

            if ((modFlags & Modifier.ISBYREF) != 0)
            {
                ec.Report.Error(1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
            }

            LocalInfo variable = ec.CurrentBlock.AddTemporaryVariable(
                ResolveParameterExpressionType(ec, Location), Location);

            variable.Resolve(ec);

            expr_tree_variable = new LocalVariableReference(
                ec.CurrentBlock, variable.Name, Location, variable, false);

            Arguments arguments = new Arguments(2);

            arguments.Add(new Argument(new TypeOf(
                                           new TypeExpression(parameter_type, Location), Location)));
            arguments.Add(new Argument(new StringConstant(Name, Location)));
            return(new SimpleAssign(ExpressionTreeVariableReference(),
                                    Expression.CreateExpressionFactoryCall(ec, "Parameter", null, arguments, Location)));
        }
Exemplo n.º 7
0
 public abstract TLocalSymbol GetLocalVariable(
     string?name,
     int slotIndex,
     LocalInfo <TTypeSymbol> info,
     ImmutableArray <bool> dynamicFlagsOpt,
     ImmutableArray <string?> tupleElementNamesOpt
     );
Exemplo n.º 8
0
        public void NavOnLoad(params object[] parsObjects)
        {
            if (parsObjects.Count() < 2)
            {
                return;
            }

            isViewActive = true;
            Msg          = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 召测指令已发送...";
            LocalInfo.Clear();

            var ctrid = (int)parsObjects[1];

            this.CtrlId = ctrid;
            var sluid = (int)parsObjects[0];

            this.SluId = sluid;

            var t = Wlst.Sr.SlusglInfoHold.Services.SluSglInfoHold.MySlef.Get(CtrlId);

            if (t == null)
            {
                return;
            }
            this.CtrlPhyId = t.CtrlId;
            this.CtrlName  = t.CtrlName;//(sluId, ctrlId);// t.CtrlName;
        }
Exemplo n.º 9
0
        public override LocalSymbol GetLocalVariable(string name, int slotIndex, LocalInfo <TypeSymbol> info, ImmutableArray <bool> dynamicFlagsOpt)
        {
            var isPinned = info.IsPinned;

            LocalDeclarationKind kind;
            RefKind    refKind;
            TypeSymbol type;

            if (info.IsByRef && isPinned)
            {
                kind    = LocalDeclarationKind.FixedVariable;
                refKind = RefKind.None;
                type    = new PointerTypeSymbol(info.Type);
            }
            else
            {
                kind    = LocalDeclarationKind.RegularVariable;
                refKind = info.IsByRef ? RefKind.Ref : RefKind.None;
                type    = info.Type;
            }

            if (!dynamicFlagsOpt.IsDefault)
            {
                type = GetDynamicType(type, refKind, dynamicFlagsOpt);
            }

            // Custom modifiers can be dropped since binding ignores custom
            // modifiers from locals and since we only need to preserve
            // the type of the original local in the generated method.
            return(new EELocalSymbol(_method, EELocalSymbol.NoLocations, name, slotIndex, kind, type, refKind, isPinned, isCompilerGenerated: false, canScheduleToStack: false));
        }
Exemplo n.º 10
0
        public override Statement VisitStmt_vardecl([NotNull] LogicScriptParser.Stmt_vardeclContext context)
        {
            var name = context.VARIABLE().GetText().TrimStart('$');

            if (Context.DoesIdentifierExist(name))
            {
                Context.Errors.AddError($"Identifier '{name}' already exists", new SourceSpan(context.VARIABLE().Symbol), true);
            }

            Expression?value = null;

            // If the variable has a bit size marker, we will use that size. Otherwise, we will later infer it from the value
            int size = context.size == null ? 0 : context.size.GetConstantValue(Context.Outer);

            if (context.expression() != null)
            {
                value = new ExpressionVisitor(Context, size).Visit(context.expression());

                if (size == 0)
                {
                    size = value.BitSize;
                }
            }
            else if (size == 0)
            {
                Context.Errors.AddError("You must specify a local's size or initialize it", context.Span(), true);
            }

            var localInfo = new LocalInfo(size, name, new SourceSpan(context.VARIABLE().Symbol));

            Context.Locals.Add(name, localInfo);

            return(new DeclareLocalStatement(context.Span(), localInfo, value));
        }
Exemplo n.º 11
0
        public LocalInfo[] GetLocals()
        {
            Func <Variable, LocalInfo>         selector = null;
            Func <RuntimeArgument, LocalInfo>  func2    = null;
            Func <DelegateArgument, LocalInfo> func3    = null;

            if ((this.locals == null) || (this.locals.Length == 0))
            {
                Activity                parent = this.activityInstance.Activity;
                List <Variable>         source = new List <Variable>();
                List <RuntimeArgument>  list2  = new List <RuntimeArgument>();
                List <DelegateArgument> list3  = new List <DelegateArgument>();
                System.Collections.Generic.HashSet <string> existingNames = new System.Collections.Generic.HashSet <string>();
                while (parent != null)
                {
                    source.AddRange(RemoveHiddenVariables(existingNames, parent.RuntimeVariables));
                    source.AddRange(RemoveHiddenVariables(existingNames, parent.ImplementationVariables));
                    if (parent.HandlerOf != null)
                    {
                        list3.AddRange(RemoveHiddenDelegateArguments(existingNames, from delegateArgument in parent.HandlerOf.RuntimeDelegateArguments select delegateArgument.BoundArgument));
                    }
                    list2.AddRange(RemoveHiddenArguments(existingNames, parent.RuntimeArguments));
                    parent = parent.Parent;
                }
                LocalInfo[] first = new LocalInfo[1];
                LocalInfo   info  = new LocalInfo {
                    Name  = "this",
                    Type  = "System.Activities.ActivityInstance",
                    Value = this.activityInstance
                };
                first[0] = info;
                if (selector == null)
                {
                    selector = variable => new LocalInfo {
                        Name = variable.Name, Location = variable.InternalGetLocation(this.activityInstance.Environment)
                    };
                }
                if (func2 == null)
                {
                    func2 = argument => new LocalInfo {
                        Name = argument.Name, Location = argument.InternalGetLocation(this.activityInstance.Environment)
                    };
                }
                if (func3 == null)
                {
                    func3 = argument => new LocalInfo {
                        Name = argument.Name, Location = argument.InternalGetLocation(this.activityInstance.Environment)
                    };
                }
                this.locals = first.Concat <LocalInfo>((from info in source.Select <Variable, LocalInfo>(selector).Concat <LocalInfo>(list2.Select <RuntimeArgument, LocalInfo>(func2)).Concat <LocalInfo>(list3.Select <DelegateArgument, LocalInfo>(func3))
                                                        orderby info.Name
                                                        select info)).ToArray <LocalInfo>();
                if (this.locals.Length > 0)
                {
                    this.CacheLocalInfos(this.locals);
                }
            }
            return(this.locals);
        }
Exemplo n.º 12
0
 public static LocalInfo GetSinglon()
 {
     if (instance == null)
     {
         instance = new LocalInfo();
     }
     return(instance);
 }
Exemplo n.º 13
0
        protected override bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, long delta, BoxedValue iterator, BoxedValueList args)
        {
            var runtime = handler.PeekRuntime();

            if (runtime.TryBreakLoop())
            {
                return(false);
            }
            var localInfos = handler.LocalInfoStack.Peek();
            var localInfo  = localInfos.GetLocalInfo(m_LocalInfoIndex) as LocalInfo;

            if (null == localInfo)
            {
                localInfo = new LocalInfo {
                    Count = m_LoadedCount.Clone(), CurCount = 0
                };
                localInfos.SetLocalInfo(m_LocalInfoIndex, localInfo);
            }
            if (!handler.PeekRuntime().CompositeReentry)
            {
                Evaluate(instance, handler, iterator, args);
            }
            bool ret = true;

            while (ret)
            {
                if (localInfo.CurCount < localInfo.Count.Value)
                {
                    Prepare(handler);
                    runtime           = handler.PeekRuntime();
                    runtime.Iterator  = localInfo.CurCount;
                    runtime.Arguments = args;
                    ++localInfo.CurCount;
                    ret = true;
                    //没有wait之类命令直接执行
                    runtime.Tick(instance, handler, delta);
                    if (runtime.CommandQueue.Count == 0)
                    {
                        handler.PopRuntime(instance);
                        if (runtime.TryBreakLoop())
                        {
                            ret = false;
                            break;
                        }
                    }
                    else
                    {
                        //遇到wait命令,跳出执行,之后直接在StoryMessageHandler里执行栈顶的命令队列(降低开销)
                        break;
                    }
                }
                else
                {
                    ret = false;
                }
            }
            return(ret);
        }
        public IXamlLocal DefineLocal(IXamlType type)
        {
            var rv = _inner.DefineLocal(type);

            _locals[rv] = new LocalInfo {
                Number = _locals.Count, Type = type
            };
            return(rv);
        }
Exemplo n.º 15
0
        protected void AddUsage(IExpression expr, bool isWrite)
        {
            bool anyIndexIsPartitioned = (expr is IArrayIndexerExpression) &&
                                         Recognizer.GetIndices(expr).Any(bracket => bracket.Any(index => Recognizer.GetVariables(index).Any(context.InputAttributes.Has <Partitioned>)));
            object decl = Recognizer.GetDeclaration(expr);

            if (decl == null || (!anyIndexIsPartitioned && context.InputAttributes.Has <LocalTransform.DoNotUseLocal>(decl)))
            {
                return;
            }
            if (containerInfos.Count == 0)
            {
                return;
            }
            ContainerInfo containerInfo = containerInfos.Peek();
            UsageInfo     usageInfo;

            if (!containerInfo.usageInfoOfVariable.TryGetValue(decl, out usageInfo))
            {
                usageInfo = new UsageInfo();
                containerInfo.usageInfoOfVariable[decl] = usageInfo;
            }
            LocalInfo info;

            if (!usageInfo.localInfos.TryGetValue(expr, out info))
            {
                info = new LocalInfo();
                info.minWriteDepth           = int.MaxValue;
                info.minReadBeforeWriteDepth = int.MaxValue;
                // this assignment is not needed since we must have depth < info.minWriteDepth
                //info.hasReadBeforeWrite = !isWrite;
                usageInfo.localInfos[expr] = info;
            }
            int depth = Recognizer.GetIndexingDepth(expr);

            if (isWrite)
            {
                info.hasWrite      = true;
                info.minWriteDepth = System.Math.Min(info.minWriteDepth, depth);
            }
            else if (depth < info.minWriteDepth)
            {
                info.hasReadBeforeWrite      = true;
                info.minReadBeforeWriteDepth = System.Math.Min(info.minReadBeforeWriteDepth, depth);
            }
            info.count++;
            if (info.containingStatements == null)
            {
                info.containingStatements = new HashSet <IStatement>(openContainers, ReferenceEqualityComparer <IStatement> .Instance);
                info.containers           = GetContainers();
            }
            else
            {
                info.containingStatements.IntersectWith(openContainers);
                info.containers = Containers.Intersect(info.containers, GetContainers(), allowBrokenLoops: true, ignoreLoopDirection: true);
            }
        }
Exemplo n.º 16
0
        public static void AnalyzeLocalDeclarationStatement(SyntaxNodeAnalysisContext context)
        {
            var localDeclaration = (LocalDeclarationStatementSyntax)context.Node;

            if (!localDeclaration.IsConst &&
                !localDeclaration.ContainsDiagnostics &&
                !localDeclaration.SpanOrTrailingTriviaContainsDirectives())
            {
                VariableDeclarationSyntax declaration = localDeclaration.Declaration;

                if (declaration != null)
                {
                    SeparatedSyntaxList <VariableDeclaratorSyntax> variables = declaration.Variables;

                    if (variables.Count == 1)
                    {
                        StatementSyntax nextStatement = localDeclaration.NextStatement();

                        if (nextStatement?.ContainsDiagnostics == false &&
                            nextStatement?.SpanOrLeadingTriviaContainsDirectives() == false)
                        {
                            SimpleAssignmentStatement assignment;
                            if (SimpleAssignmentStatement.TryCreate(nextStatement, out assignment) &&
                                assignment.Left.IsKind(SyntaxKind.IdentifierName))
                            {
                                SemanticModel     semanticModel     = context.SemanticModel;
                                CancellationToken cancellationToken = context.CancellationToken;

                                LocalInfo localInfo = FindInitializedVariable((IdentifierNameSyntax)assignment.Left, variables[0], semanticModel, cancellationToken);

                                if (localInfo.IsValid)
                                {
                                    EqualsValueClauseSyntax initializer = localInfo.Declarator.Initializer;
                                    ExpressionSyntax        value       = initializer?.Value;

                                    if (value == null ||
                                        (IsDefaultValue(declaration.Type, value, semanticModel, cancellationToken) &&
                                         !IsReferenced(localInfo.Symbol, assignment.Right, semanticModel, cancellationToken)))
                                    {
                                        context.ReportDiagnostic(DiagnosticDescriptors.MergeLocalDeclarationWithAssignment, localInfo.Declarator.Identifier);

                                        if (value != null)
                                        {
                                            context.ReportNode(DiagnosticDescriptors.MergeLocalDeclarationWithAssignmentFadeOut, initializer);
                                            context.ReportToken(DiagnosticDescriptors.MergeLocalDeclarationWithAssignmentFadeOut, assignment.AssignmentExpression.OperatorToken);
                                        }

                                        context.ReportToken(DiagnosticDescriptors.MergeLocalDeclarationWithAssignmentFadeOut, localDeclaration.SemicolonToken);
                                        context.ReportNode(DiagnosticDescriptors.MergeLocalDeclarationWithAssignmentFadeOut, assignment.Left);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        protected override IStatement ConvertFor(IForStatement ifs)
        {
            // convert the initializer, condition, and increment outside of the container.
            context.SetPrimaryOutput(ifs);
            ConvertStatement(ifs.Initializer);
            ConvertExpression(ifs.Condition);
            ConvertStatement(ifs.Increment);

            // convert the body inside of a new ContainerInfo.
            bool wasPartitioned          = this.InPartitionedLoop;
            IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs);
            bool isPartitioned           = InPartitionedLoop || context.InputAttributes.Has <Partitioned>(loopVar) || (this.compiler.UseLocals && this.compiler.OptimiseInferenceCode);

            if (isPartitioned)
            {
                this.InPartitionedLoop = true;
                containerInfos.Push(new ContainerInfo());
            }
            openContainers.Push(ifs);
            ConvertBlock(ifs.Body);
            openContainers.Pop();
            if (isPartitioned)
            {
                ContainerInfo containerInfo = containerInfos.Pop();
                var           localInfos    = new Dictionary <IExpression, LocalInfo>();
                localInfoOfStmt[ifs] = localInfos;
                // find the longest common prefix of each variable's expressions
                foreach (var entry in containerInfo.usageInfoOfVariable)
                {
                    object    decl      = entry.Key;
                    UsageInfo usageInfo = entry.Value;
                    CombineLocalInfos(usageInfo.localInfos);
                    foreach (var pair in usageInfo.localInfos)
                    {
                        IExpression expr      = pair.Key;
                        LocalInfo   localInfo = pair.Value;
                        IExpression prefix    = GetPrefixInParent(expr, loopVar);
                        if (!ReferenceEquals(prefix, expr))
                        {
                            // expr refers to this loop variable
                            IArrayIndexerExpression iaie = (IArrayIndexerExpression)expr;
                            if (usageInfo.localInfos.Count == 1)
                            {
                                localInfos.Add(expr, localInfo);
                            }
                        }
                        // add the prefix to the parent containerInfo
                        var info = AddLocalInfo(decl, prefix, localInfo, ifs);
                    }
                }
                this.InPartitionedLoop = wasPartitioned;
            }
            return(ifs);
        }
Exemplo n.º 18
0
 public void Add(LocalInfo localInfo)
 {
     this.hasWrite                = this.hasWrite || localInfo.hasWrite;
     this.minWriteDepth           = System.Math.Min(this.minWriteDepth, localInfo.minWriteDepth);
     this.hasReadBeforeWrite      = this.hasReadBeforeWrite || localInfo.hasReadBeforeWrite;
     this.minReadBeforeWriteDepth = System.Math.Min(this.minReadBeforeWriteDepth, localInfo.minReadBeforeWriteDepth);
     this.appearsInNestedLoop     = this.appearsInNestedLoop || localInfo.appearsInNestedLoop;
     this.count += localInfo.count;
     this.containingStatements.IntersectWith(localInfo.containingStatements);
     this.containers = Containers.Intersect(this.containers, localInfo.containers, allowBrokenLoops: true, ignoreLoopDirection: true);
 }
Exemplo n.º 19
0
        public LocalInfo LookupVariable(LocalInfo from)
        {
            LocalInfo result = (LocalInfo)variable_map[from];

            if (result == null)
            {
                throw new Exception("LookupVariable: looking up a variable that has not been registered yet");
            }

            return(result);
        }
Exemplo n.º 20
0
    private void Init()
    {
        mTimeCircle = transform.Find("Top/Time/Sprite");
        mTimeLabel  = transform.Find("Top/Time/Label");

        mBody       = transform.Find("Body");
        mBlueSlider = mBody.Find("Blue");
        mRedSlider  = mBody.Find("Red");

        mRoundText = mBody.Find("Round");
        mQuestion  = mBody.Find("Question");
        mAllAnswer = new List <Transform>();
        for (int i = 0; i < 4; i++)
        {
            Transform tmpAnswer = mBody.Find("Answer/" + (char)(65 + i));
            if (tmpAnswer != null)
            {
                UIEventListener.Get(tmpAnswer.gameObject).onClick += OnClickAnswer;
                mAllAnswer.Add(tmpAnswer);
            }
        }

        Transform back = transform.Find("Top/Back");

        if (back != null)
        {
            UIEventListener.Get(back.gameObject).onClick += (go) => SceneManager.LoadScene("RankPK");
        }

        // 新的一局新的AI
        GameObject ai = new GameObject("AI");

        mAI = ai.AddComponent <RedAI>();

        // 得分从0开始
        //UIHelper.SetLabel(mBlueSlider, "Score", "0");
        //UIHelper.SetLabel(mRedSlider, "Score", "0");
        UIHelper.SetSlider(mBlueSlider, 0);
        UIHelper.SetSlider(mRedSlider, 0);
        //UIHelper.SetActive(mBlueSlider, "Score", false);
        //UIHelper.SetActive(mRedSlider, "Score", false);

        // 第一回合
        mRound = 1;

        mPlayerScore = 0;
        mAIScore     = 0;

        // 初始化题目 -- 5道题测试
        int[] tmpIndex = new int[5] {
            0, 1, 2, 3, 4
        };
        curQuestions = LocalInfo.GetSinglon().GetQuestion(tmpIndex);
    }
Exemplo n.º 21
0
 void AddBlockToLocals(ILBlock block)
 {
     lock (locals)
     {
         foreach (var e in block.GetSelfAndChildrenRecursive <ILExpression>(x => x.Code == GMCode.Var))
         {
             ILVariable v = e.Operand as ILVariable;
             if (v.isGlobal)
             {
                 continue;
             }
             locals.AddOrUpdate(v.Name,
                                (key) => {
                 var info = new LocalInfo(v);
                 //  v.UserData = info;
                 return(info);
             },
                                (key, existingVal) =>
             {
                 //  v.UserData = existingVal;
                 existingVal.Add(v);
                 return(existingVal);
             });
         }
     }
     lock (assignments)
     {
         foreach (var e in block.GetSelfAndChildrenRecursive <ILExpression>(x => x.Code == GMCode.Assign))
         {
             ILVariable          vr = e.Arguments[0].Operand as ILVariable;
             List <ILExpression> vs;
             if (!assignments.TryGetValue(vr.Name, out vs))
             {
                 assignments.Add(vr.Name, vs = new List <ILExpression>());
             }
             vs.Add(e);
         }
     }
     lock (funcCalls)
     {
         foreach (var e in block.GetSelfAndChildrenRecursive <ILExpression>(x => x.Code == GMCode.Call))
         {
             ILCall c = e.Operand as ILCall;
             List <ILExpression> vs;
             if (!funcCalls.TryGetValue(c.Name, out vs))
             {
                 funcCalls.Add(c.Name, vs = new List <ILExpression>());
             }
             vs.Add(e);
         }
     }
 }
Exemplo n.º 22
0
        public void AddVariableMap(LocalInfo from, LocalInfo to)
        {
            if (variable_map == null)
            {
                variable_map = new Hashtable();
            }

            if (variable_map.Contains(from))
            {
                return;
            }
            variable_map[from] = to;
        }
Exemplo n.º 23
0
        protected override bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, long delta, object iterator, object[] args)
        {
            var localInfos = handler.LocalInfoStack.Peek();
            var localInfo  = localInfos.GetLocalInfo(m_LocalInfoIndex) as LocalInfo;

            if (null == localInfo)
            {
                localInfo = new LocalInfo {
                    List = new List <IStoryValue>()
                };
                for (int i = 0; i < m_LoadedIterators.Count; ++i)
                {
                    localInfo.List.Add(m_LoadedIterators[i].Clone());
                }
                localInfos.SetLocalInfo(m_LocalInfoIndex, localInfo);
            }
            if (!handler.PeekRuntime().CompositeReentry)
            {
                Evaluate(instance, handler, iterator, args);
            }
            bool ret = true;

            while (ret)
            {
                if (localInfo.Iterators.Count > 0)
                {
                    Prepare(handler);
                    var runtime = handler.PeekRuntime();
                    runtime.Iterator  = localInfo.Iterators.Dequeue();
                    runtime.Arguments = args;
                    ret = true;
                    //没有wait之类命令直接执行
                    runtime.Tick(instance, handler, delta);
                    if (runtime.CommandQueue.Count == 0)
                    {
                        handler.PopRuntime();
                    }
                    else
                    {
                        //遇到wait命令,跳出执行,之后直接在StoryMessageHandler里执行栈顶的命令队列(降低开销)
                        break;
                    }
                }
                else
                {
                    ret = false;
                }
            }
            return(ret);
        }
Exemplo n.º 24
0
            public LocalInfo Clone()
            {
                var result = new LocalInfo();

                result.hasReadBeforeWrite      = this.hasReadBeforeWrite;
                result.minReadBeforeWriteDepth = this.minReadBeforeWriteDepth;
                result.hasWrite            = this.hasWrite;
                result.minWriteDepth       = this.minWriteDepth;
                result.appearsInNestedLoop = this.appearsInNestedLoop;
                result.count = this.count;
                // don't need to clone containers since they are never mutated
                result.containers           = this.containers;
                result.containingStatements = new HashSet <IStatement>(this.containingStatements, this.containingStatements.Comparer);
                return(result);
            }
Exemplo n.º 25
0
        public bool MustCaptureVariable(LocalInfo local)
        {
            if (CurrentAnonymousMethod == null)
            {
                return(false);
            }

            // FIXME: IsIterator is too aggressive, we should capture only if child
            // block contains yield
            if (CurrentAnonymousMethod.IsIterator)
            {
                return(true);
            }

            return(local.Block.Toplevel != CurrentBlock.Toplevel);
        }
Exemplo n.º 26
0
        public async Task <ActionResult> Index()
        {
            var webspaceName = $"CloudClub-{WebSpaceNames.WestEuropeWebSpace}";
            var websiteName  = "CloudClub";
            var webJobInfo   = GetWebJobInfoWithRetry();
            var instanceIds  = (await client.WebSites.GetInstanceIdsAsync(webspaceName, websiteName)).ToList();

            IEnumerable <RemoteInfo> remoteInfo = new List <RemoteInfo>();
            var localInfo = new LocalInfo
            {
                WebsiteInstanceId = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID"),
                IpAddress         = Request.UserHostAddress
            };

#if DEBUG
            if (_homeModel != null)
            {
                return(View(_homeModel));
            }
#else
            if (Request.QueryString["remote"] != null)
            {
                remoteInfo = await GetRemoteInfo(
                    instanceIds.Except(new[] { localInfo.WebsiteInstanceId }, StringComparer.InvariantCultureIgnoreCase),
                    $"{Request.Url.Host}");
            }
#endif

            var model = new HomeModel
            {
                WebJobInfo  = webJobInfo,
                LocalInfo   = localInfo,
                WebsiteInfo = (await client.WebSites.GetAsync(webspaceName, websiteName, null)),
                SiteIds     = instanceIds,
                CodeGen     = HttpRuntime.CodegenDir,
                FastDrive   = Environment.ExpandEnvironmentVariables("%temp%"),
                SlowDrive   = Server.MapPath("~"),
                RemoteInfo  = remoteInfo
            };

#if DEBUG
            _homeModel = model;
#endif

            return(View(model));
        }
Exemplo n.º 27
0
        public static async Task<LocalInfo> GetLocalInfoForUrl(String zipOrLatLon)
        {
            String apiRoot = "http://api.wunderground.com/api/71170515284b31ae";
            JObject result = await GetJson(apiRoot + "/geolookup/q/" + zipOrLatLon + ".json");
            JObject location = result.GetValue("location") as JObject;
            LocalInfo info = new LocalInfo();
            info.weatherUrl = location.GetValue("requesturl").ToString();
            info.locationName = location.GetValue("city").ToString();
            if (info.weatherUrl != null && info.locationName != null)
            {
                return info;
            }
            else
            {
                return null;
            }

        }
        /// <summary>
        /// Draws the GUI element.
        /// </summary>
        /// <param name="position">The draw area.</param>
        /// <param name="property">
        /// The property representing an array <see cref="MaterialOverride"/> references.
        /// (For the same field as the property used in the constructor.)
        /// </param>
        /// <param name="label">The property label.</param>
        public void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (m_LocalOnly)
            {
                var gameObject = EditorGUIUtil.GetReferenceObject(property, m_SearchPropertyPath, false);

                if (m_LocalInfo == null || m_LocalInfo.GameObject != gameObject)
                {
                    m_LocalInfo = new LocalInfo();
                    m_LocalInfo.Load(gameObject);
                }
            }

            label = EditorGUI.BeginProperty(position, label, property);

            m_List.serializedProperty = property;
            m_List.DoList(position);

            EditorGUI.EndProperty();
        }
Exemplo n.º 29
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender">发送者</param>
        /// <param name="e">参数</param>
        private void OnOkClick(object sender, EventArgs e)
        {
            try
            {
                baseUserWebDO result;

                //账号
                if (this.cboLoginType.SelectedIndex == 0)
                {
                    login login = new login();
                    login.account    = this.txtUserName.Text.Trim();
                    login.password   = this.txtPassword.Text.Trim();
                    login.acRole     = this.UserType.ToLonginString();
                    login.macAddress = LocalInfo.GetMacAddress();
                    result           = userService.Login(login);
                }
                else //CA
                {
                    CAlogin login = new CAlogin();
                    login.caSignCert = this.txtUserName.Text.Trim();
                    login.password   = this.txtPassword.Text.Trim();
                    login.acRole     = this.UserType.ToLonginString();
                    login.macAddress = LocalInfo.GetMacAddress();
                    result           = userService.CALogin(login);
                }

                //缓存
                Cache.GetInstance().SetValue("login", result);

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MetroFramework.MetroMessageBox.Show(this, "登录失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 30
0
        void SendIPQCListStatic()
        {
            try
            {
                MyRecord.Say("-----------------开启定时发送4H不良判定统计表-------------------------");
                string body = MyConvert.ZH_TW(@"
<HTML>
<BODY style=""FONT-SIZE: 9pt; FONT-FAMILY: PMingLiU"" leftMargin=5 topMargin=5 bgColor=#ece4f3 #ffffff>
<DIV><FONT size=3 face=PMingLiU>{3}ERP系统提示您:</FONT></DIV>
<DIV><FONT size=3 face=PMingLiU>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下述表格为过去4H({0:MM.dd HH:mm}至{2:MM.dd HH:mm})制程不良判定结果的统计。</FONT></DIV>
<DIV><FONT size=3 face=PMingLiU>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (详细不良判定内容,请看附档。)</FONT></DIV>
<DIV>{1}
</DIV>
<DIV><FONT face=PMingLiU><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=4 face=PMingLiU><STRONG>&nbsp;&nbsp;此郵件由ERP系統自動發送,请勿在此郵件上直接回復。</STRONG></FONT></DIV>
<DIV><FONT color=#800080 size=2><STRONG>&nbsp;&nbsp;&nbsp;</STRONG>
<FONT color=#000000 face=PMingLiU>{2:yy/MM/dd HH:mm},由ERP系统伺服器({4})自动发送。<BR>
&nbsp;&nbsp;&nbsp;&nbsp;如自動發送功能有問題或者格式内容修改建議,請MailTo:<A href=""mailto:[email protected]"">JOHN</A><BR>
</FONT></FONT></DIV></FONT></BODY></HTML>
");
                string bbr  = @"
<FONT size=3 face=PMingLiU>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<TABLE style=""BORDER-COLLAPSE: collapse"" cellSpacing=0 cellPadding=0 width=""100%"" border=0>
  <TBODY>
	<TR>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	责任部门
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	前5大不良
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	平均不良率
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	不良数最高工序
	</TD>
	</TR>
	{0}
</TBODY></TABLE>
</FONT>
";
                string br   = @"
	<TR>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	{0}
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	{1}
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	{2:#.###%}
	</TD>
	<TD class=xl63 style=""BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"" align=center >
	{3}
	</TD>
	</TR>
";

                string   SQL     = @"
	SELECT [a].[ProcessID] AS [OccuredProcessCode], [a].[MachinID] AS [OccuredMachineCode], [a].[Numb1], [a].[Numb2], [a].[SampleNumb], [a].[AdjustNumb],
			[a].[AccNoteRdsNo], [a].[RenoteRdsno], [a].[ProduceNo] AS [ProduceRdsNo], [a].[ProductCode], [b].[RejNumb], [b].[ScrapNumber],
			[b].[AssignToDepartmentID], [b].[ProjCode], [b].[ItemID], [d].[name] AS [ProductName], [b].[Editor], [b].[EditDate], [c].[name] AS [ProjName],
			[dp].[name] AS [AssignToDepartmentName], [dp].[FullSortID], [p].[name] AS [AssignToProcessName], [p1].[name] AS [OccuredProcessName],
			[m].[name] AS [OccuredMachineName], [dp1].[name] AS [OccuredDepartmentName], [a].[RptDate],
			(ISNULL([b].[RejNumb], 0) / (ISNULL([a].[Numb1], 0) + ISNULL([a].[Numb2], 0) + ISNULL([a].[SampleNumb], 0) + ISNULL([a].[AdjustNumb], 0))) AS [Yield]
		FROM [dbo].[ProdDailyReport] [a]
			INNER JOIN [dbo].[_PMC_IPQC_List] [b] ON [a].[_ID] = [b].[zbid]
			INNER JOIN [dbo].[AllMaterialView] [d] ON [d].[code] = [a].[ProductCode]
			INNER JOIN [dbo].[moProcedure] [p1] ON [p1].[code] = [a].[ProcessID]
			INNER JOIN [dbo].[moMachine] [m] ON [m].[code] = [a].[MachinID]
			INNER JOIN [dbo].[pbDept] [dp1] ON [dp1].[_ID] = [m].[DepartmentID]
			LEFT OUTER JOIN [dbo].[_QC_Item] [c] ON [b].[ProjCode] = [c].[code]
			LEFT OUTER JOIN [dbo].[pbDept] [dp] ON [dp].[_ID] = [b].[AssignToDepartmentID]
			LEFT OUTER JOIN [dbo].[moProcedure] [p] ON [p].[code] = [b].[AssignToProcessCode]
		WHERE [a].[QCCheckDate] BETWEEN DATEADD(HOUR, -4, GETDATE()) AND GETDATE()
		ORDER BY [a].[RptDate], [a].[ProduceNo], [a].[AccNoteRdsNo]
";
                DateTime NowTime = DateTime.Now;
                string   brs     = "";
                MyRecord.Say(string.Format("后台计算定时4H不良判定统计表,{0}", NowTime));
                using (MyData.MyDataTable md = new MyData.MyDataTable(SQL))
                {
                    string fname = string.Empty;
                    MyRecord.Say("创建SendMail。");
                    MyBase.SendMail sm = new MyBase.SendMail();
                    MyRecord.Say("加载邮件内容。");
                    MyRecord.Say("计算定时发送4H不良判定统计表");
                    if (md.MyRows.IsNotEmptySet())
                    {
                        var v = from a in md.MyRows
                                select new IPQCStaticItem(a);
                        List <IPQCStaticItem> lData = v.ToList();
                        var va = from a in lData
                                 group a by a.AssignToDepartmentName into g
                                 select new
                        {
                            DepartmentName = g.Key,
                            Top5           = string.Join(",", g.GroupBy(k => k.ProjName).Select(q => new { ProjName = q.Key, RejNumb = q.Sum(p => p.RejNumb) }).OrderByDescending(x => x.RejNumb).Take(5).Select(y => string.Format("{0}:{1}", y.ProjName, y.RejNumb))),
                            AvgYeild       = g.Average(z => z.Yield),
                            TopProcessName = g.OrderBy(u => u.RejNumb).Take(1).FirstOrDefault().AssignToProcessName
                        };
                        foreach (var ri in va)
                        {
                            brs += string.Format(br, ri.DepartmentName, ri.Top5, ri.AvgYeild, ri.TopProcessName);
                        }
                        MyRecord.Say(string.Format("表格一共:{0}行,表格已经生成。", md.Rows.Count));
                        bbr = string.Format(bbr, brs);
                    }
                    else
                    {
                        bbr = @"<FONT size=5 face=PMingLiU color=Red>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 过去4H没有做过不良判定。</FONT></DIV>";
                    }

                    sm.MailBodyText = MyConvert.ZH_TW(string.Format(body, NowTime.AddHours(-4), bbr, NowTime, MyBase.CompanyTitle, LocalInfo.GetLocalIp()));
                    sm.Subject      = MyConvert.ZH_TW(string.Format("{1}{0:yy年MM月dd日HH时}_4H不良判定统计。", NowTime, MyBase.CompanyTitle));

                    MyRecord.Say("计算邮件附件内容。");
                    if (md.MyRows.IsNotEmptySet())
                    {
                        IPQCStaticItem xx;
                        var            vAttachView = from a in md.MyRows
                                                     orderby a.Value("FullSortID")
                                                     select a;

                        string[] fields   = new string[] { "ProduceRdsNo", "AccNoteRdsNo", "RptDate", "OccuredDepartmentName", "OccuredProcessName", "OccuredMachineName", "RenoteRdsno", "ProductCode", "ProductName", "Numb1", "Numb2", "SampleNumb", "AdjustNumb", "ProjName", "RejNumb", "Editor", "EditDate", "AssignToDepartmentName", "AssignToProcessName", "Yield" };
                        string[] captions = new string[] { "工单号", "完工单号", "完工日期", "发现部门", "发现工序", "发现机台", "不不良判定单号", "产品编号", "料号", "良品数", "不良数", "样品数", "过版纸数", "不良项目", "不良数", "判定人", "判定时间", "责任部门", "责任机台", "不良率" };
                        fname = ExportExcel.Export(sm, vAttachView, fields, captions, LCStr("不良判定表"));
                    }
                    ;

                    MyConfig.MailAddress mAddress = MyConfig.GetMailAddress("IPQCListStatic");
                    MyRecord.Say(string.Format("MailTO:{0}\r\nMailCC:{1}", mAddress.MailTo, mAddress.MailCC));
                    sm.MailTo = mAddress.MailTo;
                    sm.MailCC = mAddress.MailCC;
                    //sm.MailTo = "*****@*****.**";

                    MyRecord.Say("发送邮件。");
                    sm.SendOut();
                    sm.mail.Dispose();
                    sm = null;
                    MyRecord.Say("邮件已经发送。");
                    if (File.Exists(fname))
                    {
                        File.Delete(fname);
                    }
                }
                MyRecord.Say("------------------发送完成----------------------------");
            }
            catch (Exception e)
            {
                MyRecord.Say(e);
            }
        }
Exemplo n.º 31
0
        internal object EvaluateExpression(string expressionString)
        {
            // This is to shortcircuit a common case where
            // internally, vsdebugger calls our EE with literal "0"
            int intResult;

            if (int.TryParse(expressionString, out intResult))
            {
                return(intResult);
            }

            // At refresh, Expression Evaluator may re-evaluate locals/arguments.
            // To speed up the process, locals/arguments are cached.
            LocalInfo cachedLocalInfo = null;

            if (this.cachedLocalInfos != null && this.cachedLocalInfos.TryGetValue(expressionString, out cachedLocalInfo))
            {
                return(cachedLocalInfo);
            }

            Activity activity = activityInstance.Activity;
            LocationReferenceEnvironment locationReferenceEnvironment = activity.PublicEnvironment;

            // a temporary context for EvaluateExpression
            // We're not using the executor so it's ok that it's null
            CodeActivityContext context = new CodeActivityContext(activityInstance, null);

            object result;

            try
            {
                // First try as R-Value
                if (!TryEvaluateExpression(expressionString, null, locationReferenceEnvironment, context, out result))
                {
                    return(SR.DebugInfoCannotEvaluateExpression(expressionString));
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
                context.Dispose();
                return(SR.DebugInfoCannotEvaluateExpression(expressionString));
            }

            // Now try expression as an L-Value if possible.
            try
            {
                object resultLocation;
                if (TryEvaluateExpression(expressionString, result.GetType(), locationReferenceEnvironment, context, out resultLocation))
                {
                    LocalInfo localInfo = new LocalInfo()
                    {
                        Name     = expressionString,
                        Location = resultLocation as Location
                    };
                    this.cachedLocalInfos[expressionString] = localInfo;
                    return(localInfo);
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
            }
            finally
            {
                context.Dispose();
            }
            return(result);
        }
Exemplo n.º 32
0
        internal object EvaluateExpression(string expressionString)
        {
            // This is to shortcircuit a common case where 
            // internally, vsdebugger calls our EE with literal "0"            
            int intResult;
            if (int.TryParse(expressionString, out intResult))
            {
                return intResult;
            }

            // At refresh, Expression Evaluator may re-evaluate locals/arguments.
            // To speed up the process, locals/arguments are cached.
            LocalInfo cachedLocalInfo = null;
            if (this.cachedLocalInfos != null && this.cachedLocalInfos.TryGetValue(expressionString, out cachedLocalInfo))
            {
                return cachedLocalInfo;
            }

            Activity activity = activityInstance.Activity;
            LocationReferenceEnvironment locationReferenceEnvironment = activity.PublicEnvironment;

            // a temporary context for EvaluateExpression
            // We're not using the executor so it's ok that it's null
            CodeActivityContext context = new CodeActivityContext(activityInstance, null);

            object result;
            try
            {
                // First try as R-Value
                if (!TryEvaluateExpression(expressionString, null, locationReferenceEnvironment, context, out result))
                {
                    return SR.DebugInfoCannotEvaluateExpression(expressionString);
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
                context.Dispose();
                return SR.DebugInfoCannotEvaluateExpression(expressionString);
            }

            // Now try expression as an L-Value if possible.
            try
            {
                object resultLocation;
                if (TryEvaluateExpression(expressionString, result.GetType(), locationReferenceEnvironment, context, out resultLocation))
                {
                    LocalInfo localInfo = new LocalInfo()
                                            {
                                                Name = expressionString,
                                                Location = resultLocation as Location
                                            };
                    this.cachedLocalInfos[expressionString] = localInfo;
                    return localInfo;
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
            }
            finally
            {
                context.Dispose();
            }
            return result;
        }
Exemplo n.º 33
0
 // Cache local infos for faster evaluation.
 void CacheLocalInfos(LocalInfo[] localInfos)
 {
     if (this.cachedLocalInfos == null)
     {
         this.cachedLocalInfos = new Dictionary<string, LocalInfo>(StringComparer.OrdinalIgnoreCase);
     }
     foreach (LocalInfo localInfo in localInfos)
     {
         this.cachedLocalInfos[localInfo.Name] = localInfo;
     }
 }
		bool Initialize(List<Block> allBlocks) {
			localInfos.Clear();
			foreach (var local in blocks.Locals)
				localInfos[local] = new LocalInfo(local);
			if (localInfos.Count == 0)
				return false;

			foreach (var block in allBlocks) {
				var instrs = block.Instructions;
				for (int i = 0; i < instrs.Count - 1; i++) {
					var ldloc = instrs[i];
					if (!ldloc.IsLdloc())
						continue;
					var local = ldloc.Instruction.GetLocal(blocks.Locals);
					if (local == null)
						continue;
					var localInfo = localInfos[local];
					localInfo.CastType = GetCastType(instrs[i + 1]);
				}
			}
			return true;
		}