Ejemplo n.º 1
0
        public override JSValue Evaluate(Context context)
        {
            JSValue imageValue = null;
            int     caseIndex  = 1;
            int     lineIndex  = Cases[0].index;

            if (context._executionMode >= ExecutionMode.Resume)
            {
                var sdata = context.SuspendData[this] as SuspendData;
                imageValue = sdata.imageValue ?? image.Evaluate(context);
                caseIndex  = sdata.caseIndex;
                lineIndex  = sdata.lineIndex;
            }
            else
            {
                if (context.Debugging)
                {
                    context.raiseDebugger(image);
                }

                imageValue = image.Evaluate(context);
            }
            if (context._executionMode == ExecutionMode.Suspend)
            {
                context.SuspendData[this] = new SuspendData {
                    caseIndex = 1
                };
                return(null);
            }

            for (; caseIndex < Cases.Length; caseIndex++)
            {
                if (context.Debugging)
                {
                    context.raiseDebugger(Cases[caseIndex].statement);
                }

                var cseResult = Cases[caseIndex].statement.Evaluate(context);
                if (context._executionMode == ExecutionMode.Suspend)
                {
                    context.SuspendData[this] = new SuspendData
                    {
                        caseIndex  = caseIndex,
                        imageValue = imageValue
                    };
                    return(null);
                }

                if (StrictEqual.Check(imageValue, cseResult))
                {
                    lineIndex = Cases[caseIndex].index;
                    caseIndex = Cases.Length;
                    break;
                }
            }
            for (; lineIndex < Body.Length; lineIndex++)
            {
                if (Body[lineIndex] == null)
                {
                    continue;
                }

                context._lastResult = Body[lineIndex].Evaluate(context) ?? context._lastResult;
                if (context._executionMode != ExecutionMode.None)
                {
                    if (context._executionMode == ExecutionMode.Break)
                    {
                        context._executionMode = ExecutionMode.None;
                    }
                    else if (context._executionMode == ExecutionMode.Suspend)
                    {
                        context.SuspendData[this] = new SuspendData
                        {
                            caseIndex  = caseIndex,
                            imageValue = imageValue,
                            lineIndex  = lineIndex
                        };
                    }
                    return(null);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
 internal protected virtual T Visit(StrictEqual node)
 {
     return(Visit(node as Expression));
 }
Ejemplo n.º 3
0
 protected override EP_VP1 Visit(StrictEqual node)
 {
     node.Children[1].Visit(this);
     node.Children[0].Visit(this);
     return(this);
 }