public static string evaluateLines(SpokeLine[] lines, int tabIndex)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var spokeLine in lines)
            {
                sb.Append(getLine(spokeLine, tabIndex));
            }
            return sb.ToString();
        }
Exemplo n.º 2
0
        public static string getLine(SpokeLine spokeLine, int tabIndex)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            for (int i = 0; i < tabIndex; i++)
            {
                sb.Append("  \t");
            }

            switch (spokeLine.LType)
            {
            case ISpokeLine.If:
                sb.Append("If ");
                sb.Append(evalute(((SpokeIf)spokeLine).Condition, tabIndex));
                sb.AppendLine(evaluateLines(((SpokeIf)spokeLine).IfLines.ToArray(), tabIndex + 1));
                if (((SpokeIf)spokeLine).ElseLines != null)
                {
                    for (int i = 0; i < tabIndex; i++)
                    {
                        sb.Append("  \t");
                    }
                    sb.Append("Else  ");
                    sb.AppendLine(evaluateLines(((SpokeIf)spokeLine).ElseLines.ToArray(), tabIndex + 1));
                }

                break;

            case ISpokeLine.Return:
                sb.Append("Return ");
                sb.Append(evalute(((SpokeReturn)spokeLine).Return, tabIndex));
                break;

            case ISpokeLine.Yield: sb.Append("Yield ");
                sb.Append(evalute(((SpokeYield)spokeLine).Yield, tabIndex));
                break;

            case ISpokeLine.YieldReturn:
                sb.Append("Yield Return ");
                sb.Append(evalute(((SpokeYieldReturn)spokeLine).YieldReturn, tabIndex));
                break;

            case ISpokeLine.MethodCall:


                sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                break;

            case ISpokeLine.AnonMethod:
                sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                break;

            case ISpokeLine.Construct:
                sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                break;

            case ISpokeLine.Set:

                var grf = ((SpokeEqual)spokeLine);
                sb.Append("Set ");
                sb.Append(evalute(grf.LeftSide, tabIndex));
                sb.Append("=");

                sb.Append(evalute(grf.RightSide, tabIndex));


                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(sb.ToString());
        }
Exemplo n.º 3
0
        private SpokeObject evaluateLines(SpokeLine[] lines, SpokeMethodRun currentObject, SpokeObject[] variables)
        {
            #if Stacktrace
            File.WriteAllText("C:\\mna.txt", dfss.ToString());
            #endif

            foreach (var spokeLine in lines)
            {

            #if Stacktrace
                dfss.AppendLine(spokeLine.ToString());
            #endif

                switch (spokeLine.LType)
                {
                    case ISpokeLine.If:
                        var b = evalute(((SpokeIf)spokeLine).Condition, currentObject, variables);
                        if (b.BoolVal)
                        {
                            var df = evaluateLines(((SpokeIf)spokeLine).IfLines, currentObject, variables);
                            if (df != null)
                            {
                                return df;
                            }
                        }
                        else
                        {
                            if (((SpokeIf)spokeLine).ElseLines != null)
                            {
                                var df = evaluateLines(((SpokeIf)spokeLine).ElseLines, currentObject, variables);
                                if (df != null)
                                {
                                    return df;
                                }
                            }
                        }
                        break;
                    case ISpokeLine.Return:
                        if (((SpokeReturn)spokeLine).Return == null)
                        {
                            return NULL;
                        }
                        return evalute(((SpokeReturn)spokeLine).Return, currentObject, variables);
                        break;
                    //case ISpokeLine.Yield:
                    //    currentObject.ForYield.Add(evalute(((SpokeYield)spokeLine).Yield, currentObject, variables));
                    //    break;
                    //case ISpokeLine.YieldReturn:
                    //    SpokeObject d;
                    //    currentObject.ForYield.Add(d = evalute(((SpokeYieldReturn)spokeLine).YieldReturn, currentObject, variables));
                    //    return d;
                    //    break;
                    case ISpokeLine.MethodCall:

                        evalute((SpokeItem)spokeLine, currentObject, variables, true);
                        break;
                    case ISpokeLine.AnonMethod:
                        var arm = evalute((SpokeItem)spokeLine, currentObject, variables, true);
                        if (arm != null && !((SpokeAnonMethod)spokeLine).SpecAnon)
                        {
                            return arm;
                        }
                        break;
                    case ISpokeLine.Construct:
                        return evalute((SpokeItem)spokeLine, currentObject, variables);
                        break;
                    case ISpokeLine.Set:

                        var grf = ((SpokeEqual)spokeLine);

                        var right = evalute(grf.RightSide, currentObject, variables);

                        SpokeObject left;
                        switch (right.Type)
                        {
                            case ObjectType.Null:
                                break;
                            case ObjectType.Int:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Int;
                                left.IntVal = right.IntVal;

                                break;
                            case ObjectType.String:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.String;
                                left.StringVal = right.StringVal;

                                break;
                            case ObjectType.Float:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Float;
                                left.FloatVal = right.FloatVal;

                                break;
                            case ObjectType.Bool:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Bool;
                                left.BoolVal = right.BoolVal;

                                break;
                            case ObjectType.Array:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Array;
                                left.ArrayItems = new List<SpokeObject>(right.ArrayItems);
                                break;
                            case ObjectType.Object:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Object;
                                left.Variables = (SpokeObject[])right.Variables.Clone();

                                break;
                            case ObjectType.Method:
                                left = evalute(grf.LeftSide, currentObject, variables);
                                left.Type = ObjectType.Method;
                                left.AnonMethod = right.AnonMethod;
                                left.Variables = right.Variables;
                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
            return null;
        }
		private bool linesHave(SpokeLine[] lines, ISpokeLine r)
		{
			for (int index = 0; index < lines.Length; index++)
			{
				var e = lines[index];
				if (e.LType == r)
				{
					return true;
				}
				if (e is SpokeLines && (!(e is SpokeAnonMethod) || (r == ISpokeLine.Return)))
				{

					if (e is SpokeAnonMethod)
					{
						if (linesHave(((SpokeLines)e).Lines, ISpokeLine.Return) || linesHave(((SpokeLines)e).Lines, ISpokeLine.Yield) || linesHave(((SpokeLines)e).Lines, ISpokeLine.YieldReturn))
						{
							return true;
						}
					}
					else
						if (linesHave(((SpokeLines)e).Lines, r))
						{
							return true;
						}
				}

			}
			return false;
		}
        public static string getLine(SpokeLine spokeLine,int tabIndex)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine();
            for (int i = 0; i < tabIndex; i++)
            {
                sb.Append("  \t");

            }

            switch (spokeLine.LType)
            {
                case ISpokeLine.If:
                    sb.Append("If ");
                    sb.Append(evalute(((SpokeIf)spokeLine).Condition, tabIndex));
                    sb.AppendLine(evaluateLines(((SpokeIf)spokeLine).IfLines.ToArray(), tabIndex + 1));
                    if (((SpokeIf)spokeLine).ElseLines != null)
                    {
                        for (int i = 0; i < tabIndex; i++)
                        {
                            sb.Append("  \t");
                        }
                        sb.Append("Else  ");
                        sb.AppendLine(evaluateLines(((SpokeIf)spokeLine).ElseLines.ToArray(), tabIndex + 1));
                    }

                    break;
                case ISpokeLine.Switch:
                    sb.Append("switch ");

                    break;
                case ISpokeLine.Return:
                    sb.Append("Return ");
                    sb.Append(evalute(((SpokeReturn)spokeLine).Return, tabIndex));
                    break;
                case ISpokeLine.Yield: sb.Append("Yield ");
                    sb.Append(evalute(((SpokeYield)spokeLine).Yield, tabIndex));
                    break;
                case ISpokeLine.YieldReturn:
                    sb.Append("Yield Return ");
                    sb.Append(evalute(((SpokeYieldReturn)spokeLine).YieldReturn, tabIndex));
                    break;
                case ISpokeLine.MethodCall:

                    sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                    break;
                case ISpokeLine.AnonMethod:
                    sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                    break;
                case ISpokeLine.Construct:
                    sb.Append(evalute((SpokeItem)spokeLine, tabIndex));
                    break;
                case ISpokeLine.Set:

                    var grf = ((SpokeEqual)spokeLine);
                    sb.Append("Set ");
                    sb.Append(evalute(grf.LeftSide, tabIndex));
                    sb.Append("=");

                    sb.Append(evalute(grf.RightSide, tabIndex));

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
            return sb.ToString();
        }
 private void resetGuids(SpokeLine l)
 {
     if (l is s)
     {
         ((s)l).resetGUID();
     }
     if (l is SpokeLines)
     {
         foreach (var spokeLine in ((SpokeLines)l).Lines)
         {
             resetGuids(spokeLine);
         }
     }
 }
        private SpokeType evaluateLines(ref SpokeLine[] lines, SpokeMethodParse currentObject, SpokeVariableInfo variables)
        {
            List<SpokeLine> ln = new List<SpokeLine>(lines);
            int jumpIndex = 0;

            for (int index = 0; index < lines.Length; index++)
            {
                var spokeLine = lines[index];

                SpokeType df;
                List<SpokeInstruction> ddsf;
                switch (spokeLine.LType)
                {
                    case ISpokeLine.Switch:
                        evaluateSwitch(currentObject, variables,
                                (SpokeSwitch)spokeLine);

                        break;
                    case ISpokeLine.If:
                        var b = evaluateItem(((SpokeIf)spokeLine).Condition, currentObject, variables);

                        if (b.Type != ObjectType.Bool)
                        {
                            throw new AbandonedMutexException("Expected bool");
                        }

                        new SpokeInstruction(SpokeInstructionType.IfTrueContinueElse, ((SpokeIf)spokeLine).ElseLines == null ? "EndIf" + ((SpokeIf)spokeLine).Guid : "ElseIf" + ((SpokeIf)spokeLine).Guid);

                        variables.IncreaseState();
                        df = evaluateLines(ref ((SpokeIf)spokeLine).IfLines, currentObject, variables);
                        variables.DecreaseState();
                        if (currentObject.ReturnType != null && !currentObject.ReturnType.CompareTo(df, true))
                        {
                            throw new AbandonedMutexException("for return:    Expected " + currentObject.ReturnType.Type +
                                                              " Got" + df.Type);
                        }

                        if (((SpokeIf)spokeLine).ElseLines != null)
                        {
                            new SpokeInstruction(SpokeInstructionType.Goto, "EndIf" + ((SpokeIf)spokeLine).Guid);
                            new SpokeInstruction(SpokeInstructionType.Label, "ElseIf" + ((SpokeIf)spokeLine).Guid);

                            df = evaluateLines(ref ((SpokeIf)spokeLine).ElseLines, currentObject,
                                               variables);
                            {
                                if (currentObject.ReturnType != null && !currentObject.ReturnType.CompareTo(df, true))
                                {
                                    throw new AbandonedMutexException("for return:    Expected " + currentObject.ReturnType.Type + " Got" + df.Type);
                                }
                            }
                        }
                        new SpokeInstruction(SpokeInstructionType.Label, "EndIf" + ((SpokeIf)spokeLine).Guid);

                        break;
                    case ISpokeLine.Return:
                        int va;
                        if (((SpokeReturn)spokeLine).Return == null)
                        {
                            currentObject.ReturnType = new SpokeType(ObjectType.Null);
                            new SpokeInstruction(SpokeInstructionType.Null);

                            if (!anonMethodsEntered.Any() || anonMethodsEntered.All(a => !a.Value))
                                new SpokeInstruction(SpokeInstructionType.Return);
                            else
                            {
                                new SpokeInstruction(SpokeInstructionType.StoreLocalObject, va = variables.Add("__tmpReturn" + ((SpokeReturn)spokeLine).Guid, currentObject.ReturnType, null));
                                new SpokeInstruction(SpokeInstructionType.GetLocal, va);
                                new SpokeInstruction(SpokeInstructionType.Goto, anonMethodsEntered.Last(a => a.Value).Key);
                            }
                        }
                        else
                        {
                            df = evaluateItem(((SpokeReturn)spokeLine).Return, currentObject, variables);

                            if (currentObject.ReturnType.CompareTo(df, true))
                            {
                                if (currentObject.ReturnType.Type == ObjectType.Unset)
                                {
                                    currentObject.ReturnType = df;
                                }
                            }
                            else
                            {
                                throw new AbandonedMutexException("for return:    Expected " +
                                                                  currentObject.ReturnType.Type + " Got" + df.Type);
                            }

                            if (!anonMethodsEntered.Any() || anonMethodsEntered.All(a => !a.Value))
                                new SpokeInstruction(SpokeInstructionType.Return);
                            else
                            {
                                setInstru(currentObject.ReturnType.Type, va = variables.Add("__tmpReturn" + ((SpokeReturn)spokeLine).Guid, currentObject.ReturnType, null));

                                new SpokeInstruction(SpokeInstructionType.GetLocal, va);

                                new SpokeInstruction(SpokeInstructionType.Goto, anonMethodsEntered.Last(a => a.Value).Key);
                            }

                        }

                        break;
                    case ISpokeLine.Yield:
                        ddsf = new List<SpokeInstruction>(SpokeInstruction.ins);
                        df = evaluateItem(((SpokeYield)spokeLine).Yield, currentObject, variables);
                        SpokeInstruction.ins = ddsf;
                        if (currentObject.ForYieldArray.CompareTo(df, true))
                        {
                            if (currentObject.ForYieldArray.Type == ObjectType.Unset)
                            {
                                currentObject.ForYieldArray = df;
                            }
                        }
                        else
                        {
                            throw new AbandonedMutexException("for yield:    Expected " +
                                                              currentObject.ForYieldArray.Type + " Got" + df.Type);
                        }

                        break;
                    case ISpokeLine.YieldReturn:
                        ddsf = new List<SpokeInstruction>(SpokeInstruction.ins);
                        df = evaluateItem(((SpokeYieldReturn)spokeLine).YieldReturn, currentObject, variables);
                        SpokeInstruction.ins = ddsf;
                        if (currentObject.ForYieldArray.CompareTo(df, true))
                        {
                            if (currentObject.ForYieldArray.Type == ObjectType.Unset)
                            {
                                currentObject.ForYieldArray = df;
                            }
                        }
                        else
                        {
                            throw new AbandonedMutexException("for yield:    Expected " +
                                                              currentObject.ForYieldArray.Type + " Got" + df.Type);
                        }

                        break;
                    case ISpokeLine.MethodCall:
                        var def = evaluateItem((SpokeItem)spokeLine, currentObject, variables, true);
                        if (def == null)
                        {
                            //        Console.WriteLine("A");
                        }
                        else
                            //if (def.Type == ObjectType.Void)
                            //{
                            //     new SpokeInstruction(SpokeInstructionType.PopStack);
                            //}
                            new SpokeInstruction(SpokeInstructionType.PopStack);

                        //no care about the typiola
                        break;
                    case ISpokeLine.AnonMethod:
                        var arm = evaluateItem((SpokeItem)spokeLine, currentObject, variables, true);

                        if (((SpokeAnonMethod)spokeLine).HasReturn)
                        {

                            //    ln[index] = new SpokeReturn() { Return = (SpokeAnonMethod)spokeLine };

                            //                            if (!anonMethodsEntered.Any())
                            //                                new SpokeInstruction(SpokeInstructionType.Return);
                            //                            else
                            //                            {
                            //                                new SpokeInstruction(SpokeInstructionType.Goto, anonMethodsEntered.Last().Key);
                            //                            }

                            if (arm == null)
                            {
                                throw new AbandonedMutexException("AIDS");
                            }
                            if (currentObject.ReturnType.CompareTo(arm, true))
                            {
                                if (currentObject.ReturnType.Type == ObjectType.Unset)
                                {
                                    currentObject.ReturnType = arm;
                                }
                            }
                            else
                            {
                                throw new AbandonedMutexException("for anonMethod:    Expected " +
                                                                  currentObject.ReturnType.Type + " Got" + arm.Type);
                            }
                        }
                        else if (((SpokeAnonMethod)spokeLine).HasYield || ((SpokeAnonMethod)spokeLine).HasYieldReturn)
                        {
                            //   ln[index] = new SpokeReturn() { Return = (SpokeAnonMethod)spokeLine };

                            //                          if (!anonMethodsEntered.Any())
                            //                              new SpokeInstruction(SpokeInstructionType.Return);
                            //                          else
                            //                          {
                            //                              new SpokeInstruction(SpokeInstructionType.Goto, anonMethodsEntered.Last().Key);
                            //                          }

                            ln.Insert(index + 1, new SpokeReturn() { Return = ((SpokeAnonMethod)spokeLine) });
                            ln.Remove(spokeLine);
                            jumpIndex++;

                        }
                        //     else
                        //        new SpokeInstruction(SpokeInstructionType.PopStack);

                        //if ((((SpokeAnonMethod)spokeLine).Lines[0] is SpokeEqual && ((SpokeEqual)((SpokeAnonMethod)spokeLine).Lines[0]).RightSide.IType==ISpokeItem.Array))
                        //{

                        //}

                        //ln.Insert(index + jumpIndex, ((SpokeAnonMethod)spokeLine).Lines[0]);

                        //jumpIndex++;

                        //var dfe = new List<SpokeLine>(((SpokeAnonMethod)spokeLine).Lines);
                        //dfe.RemoveAt(0);
                        //((SpokeAnonMethod)spokeLine).Lines = dfe.ToArray();

                        if (arm == null)
                        {
                            continue;
                        }
                        //var barm = new SpokeType(ObjectType.Array) { ArrayItemType = arm, ClassName = "Array" };

                        if (currentObject.ReturnType.CompareTo(arm, true))
                        {
                            if (currentObject.ReturnType.Type == ObjectType.Unset)
                            {
                                currentObject.ReturnType = arm;
                            }
                        }
                        else
                        {
                            throw new AbandonedMutexException("for anonMethod:    Expected " +
                                                              currentObject.ForYieldArray.Type + " Got" +
                                                              arm.Type);
                        }

                        break;
                    case ISpokeLine.Construct:
                        var d = evaluateItem((SpokeItem)spokeLine, currentObject, variables);

                        return d;
                        break;
                    case ISpokeLine.Set:

                        var grf = ((SpokeEqual)spokeLine);

                        var right = evaluateItem(grf.RightSide, currentObject, variables);

                        forSet = true;
                        SpokeType left;
                        switch (right.Type)
                        {
                            case ObjectType.Null:
                                throw new AbandonedMutexException("Set bad");
                                break;
                            case ObjectType.Int:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                {
                                    //throw new AbandonedMutexException("Set bad");
                                }

                                break;
                            case ObjectType.String:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                    throw new AbandonedMutexException("Set bad");

                                break;
                            case ObjectType.Float:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                {
                                    //throw new AbandonedMutexException("Set bad");
                                }

                                break;
                            case ObjectType.Bool:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                    throw new AbandonedMutexException("Set bad");
                                break;
                            case ObjectType.Array:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                    throw new AbandonedMutexException("Set bad");
                                break;
                            case ObjectType.Object:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                    throw new AbandonedMutexException("Set bad");
                                left.ClassName = right.ClassName;
                                if (right.Variables != null)
                                    left.Variables = new SpokeVariableInfo(right.Variables);

                                break;
                            case ObjectType.Method:
                                left = evaluateItem(grf.LeftSide, currentObject, variables);
                                if (!left.CompareTo(right, true))
                                    if (!(left.Type == ObjectType.Object && left.Variables.index == 0))
                                    {
                                        throw new AbandonedMutexException("Set bad");
                                    }
                                    else
                                    {
                                        left.ClassName = right.ClassName;
                                        left.AnonMethod = right.AnonMethod;
                                        left.Type = right.Type;
                                        left.ArrayItemType = right.ArrayItemType;
                                        if (right.Variables != null)
                                            left.Variables = new SpokeVariableInfo(right.Variables);
                                        left.MethodType = right.MethodType;

                                    }

                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                                break;
                        }

                        switch (SpokeInstruction.ins.Last().Type)
                        {
                            case SpokeInstructionType.GetLocal:

                                if (left.ByRef)
                                {
                                    SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalRef;
                                }
                                else
                                {
                                    switch (right.Type)
                                    {
                                        case ObjectType.Null:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalObject;
                                            break;
                                        case ObjectType.Int:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalInt;
                                            break;
                                        case ObjectType.Float:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalFloat;
                                            break;
                                        case ObjectType.String:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalString;
                                            break;
                                        case ObjectType.Bool:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalBool;
                                            break;
                                        case ObjectType.Array:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalObject;
                                            break;
                                        case ObjectType.Object:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalObject;
                                            break;
                                        case ObjectType.Method:
                                            SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreLocalMethod;
                                            break;
                                        case ObjectType.Void:
                                            break;
                                        default:
                                            throw new ArgumentOutOfRangeException();
                                    }
                                }

                                break;
                            case SpokeInstructionType.GetField:

                                switch (right.Type)
                                {
                                    case ObjectType.Null:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldObject;
                                        break;
                                    case ObjectType.Int:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldInt;
                                        break;
                                    case ObjectType.Float:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldFloat;
                                        break;
                                    case ObjectType.String:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldString;
                                        break;
                                    case ObjectType.Bool:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldBool;
                                        break;
                                    case ObjectType.Array:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldObject;
                                        break;
                                    case ObjectType.Object:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldObject;
                                        break;
                                    case ObjectType.Method:
                                        SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreFieldMethod;
                                        break;
                                    case ObjectType.Void:
                                        break;
                                    default:
                                        throw new ArgumentOutOfRangeException();
                                }

                                break;
                            case SpokeInstructionType.ArrayElem:
                                SpokeInstruction.ins[SpokeInstruction.ins.Count - 1].Type = SpokeInstructionType.StoreArrayElem;
                                break;
                        }

                        if (left.Type == ObjectType.Unset)
                        {
                            left.ClassName = right.ClassName;
                            left.AnonMethod = right.AnonMethod;
                            left.Type = right.Type;
                            left.ArrayItemType = right.ArrayItemType;
                            if (right.Variables != null)
                                left.Variables = new SpokeVariableInfo(right.Variables);
                            left.MethodType = right.MethodType;
                        }

                        else
                        {
                            if (!left.CompareTo(right, false))
                            {
                                //  throw new AbandonedMutexException("hmm");
                            }
                        }
                        forSet = false;

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            lines = ln.ToArray();

            if (currentObject.ReturnType != null)
                return currentObject.ReturnType;

            return null;
        }
Exemplo n.º 8
0
 public Case(SpokeItem i, SpokeLine[] l)
 {
     Item = i;
     Lines = l;
 }