Ejemplo n.º 1
0
    public void CheckEnvironment()
    {
        Collider2D[] colliders  = Physics2D.OverlapPointAll(transform.position + colliderOffset);
        bool         envEntered = false;

        foreach (Collider2D collider in colliders)
        {
            Environment newEnvironment = collider.GetComponent <Environment>();
            if (newEnvironment != null)
            {
                if (current.GetType() != newEnvironment.GetType())
                {
                    newEnvironment.Enter(this.gameObject);
                    current.Exit(this.gameObject);
                    current = newEnvironment;
                }
                else
                {
                    newEnvironment.Stay(this.gameObject);
                }
                envEntered = true;
                break;
            }
            else
            {
                continue;
            }
        }

        if (!envEntered)
        {
            current.Exit(this.gameObject);
            current = new NullEnvironment();
        }
    }
Ejemplo n.º 2
0
        public async void TestNullEnvironment()
        {
            NullEnvironment testNullEnvironment = NullEnvironment.Instance;

            Assert.NotNull(testNullEnvironment);

            var       token         = new CancellationToken();
            ModuleSet testModuleSet = await testNullEnvironment.GetModulesAsync(token);

            Assert.NotNull(testModuleSet);
            Assert.Equal(testModuleSet, ModuleSet.Empty);

            IRuntimeInfo runtimeInfo = await testNullEnvironment.GetRuntimeInfoAsync();

            Assert.NotNull(runtimeInfo);
            Assert.True(ReferenceEquals(runtimeInfo, UnknownRuntimeInfo.Instance));
        }
Ejemplo n.º 3
0
        public static bool ObjectSetType(out object answer, object arg0, object arg1)
        {
            TC newType = (TC) (int) arg0;
            // kludge!!!!
            if ((int) arg0 == 0 && (int) arg1 == 1)
                answer = new NullEnvironment ();
            else
            switch (newType)
            {
                case TC.COMBINATION_2:
                    answer = Combination2.Make ((Hunk3) arg1);
                    break;

                case TC.CONDITIONAL:
                    answer = Conditional.Make ((Hunk3) arg1);
                    break;

                case TC.CONSTANT:
                    answer = Constant.Decode ((uint) (int) arg1);
                    break;

                case TC.HUNK3_A:
                    // Probably someone trying to mark a history object.
                    answer = arg1;
                    break;

                case TC.HUNK3_B:
                    answer = arg1;
                    break;

                case TC.ENVIRONMENT:
                    object [] args = (object[]) arg1;
                    StandardClosure closure = (StandardClosure) args [0];
                    object [] actualArgs = new object [args.Length - 1];
                    for (int i = 0; i < actualArgs.Length; i++)
                        actualArgs [i] = args [i + 1];
                    answer = new StandardEnvironment<StandardLambda,StandardClosure> (closure, actualArgs);
                    break;

                     // throw new NotImplementedException ();
            //            // answer = (new InterpreterEnvironment ((object []) arg1));

                case TC.EXTENDED_LAMBDA:
                    answer = ExtendedLambda.Make ((Hunk3) arg1);
                    break;

                case TC.PCOMB0:
                    answer = PrimitiveCombination0.Make ((Primitive0) arg1);
                    break;

                case TC.PCOMB2:
                    answer = PrimitiveCombination2.Make ((Hunk3) arg1);
                    break;

                case TC.PRIMITIVE:
                    if (!(arg1 is PrimitiveCombination0))
                        throw new NotImplementedException ("Object-set-type on primitive");
                    answer = ((PrimitiveCombination0) arg1).Operator;
                    break;

                case TC.RECORD:
                    answer = new Record ((object []) arg1);
                    return false;

                case TC.SEQUENCE_3:
                    answer = new Sequence3 ((Hunk3) arg1);
                    break;

                case TC.THE_ENVIRONMENT:
                    answer = TheEnvironment.Make();
                    break;

                case TC.VARIABLE:
                    answer =  Variable.Make ((Hunk3) arg1);
                    break;

                case TC.VECTOR:
                    // Someone wants to see what endian we are!
                    char [] source = (char []) arg1;
                    object [] result = new object [source.Length / 4];
                    result [1] = ((((((byte) source [3]) * 256)
                        + ((byte) source [2])) * 256)
                        + ((byte) source [1])) * 256
                        + ((byte) source [0]);
                    result [0] = ((((((byte) source [7]) * 256)
                                        + ((byte) source [6])) * 256)
                                        + ((byte) source [5])) * 256
                                        + ((byte) source [4]);
                    answer = result;
                    break;

                case TC.WEAK_CONS:
                    answer = new WeakCons (((Cons) arg1).Car, ((Cons) arg1).Cdr);
                    break;

               default:
                    throw new NotImplementedException ();
            }
            return false;
        }
Ejemplo n.º 4
0
 void Awake()
 {
     current        = new NullEnvironment();
     colliderOffset = Vector3.zero;
 }
Ejemplo n.º 5
0
        public static bool ObjectSetType(out object answer, object arg0, object arg1)
        {
            TC newType = (TC)(int)arg0;

            // kludge!!!!
            if ((int)arg0 == 0 && (int)arg1 == 1)
            {
                answer = new NullEnvironment();
            }
            else
            {
                switch (newType)
                {
                case TC.COMBINATION_2:
                    answer = Combination2.Make((Hunk3)arg1);
                    break;

                case TC.CONDITIONAL:
                    answer = Conditional.Make((Hunk3)arg1);
                    break;

                case TC.CONSTANT:
                    answer = Constant.Decode((uint)(int)arg1);
                    break;

                case TC.HUNK3_A:
                    // Probably someone trying to mark a history object.
                    answer = arg1;
                    break;

                case TC.HUNK3_B:
                    answer = arg1;
                    break;

                case TC.ENVIRONMENT:
                    object []       args       = (object[])arg1;
                    StandardClosure closure    = (StandardClosure)args [0];
                    object []       actualArgs = new object [args.Length - 1];
                    for (int i = 0; i < actualArgs.Length; i++)
                    {
                        actualArgs [i] = args [i + 1];
                    }
                    answer = new StandardEnvironment <StandardLambda, StandardClosure> (closure, actualArgs);
                    break;

                // throw new NotImplementedException ();
                //            // answer = (new InterpreterEnvironment ((object []) arg1));

                case TC.EXTENDED_LAMBDA:
                    answer = ExtendedLambda.Make((Hunk3)arg1);
                    break;

                case TC.PCOMB0:
                    answer = PrimitiveCombination0.Make((Primitive0)arg1);
                    break;

                case TC.PCOMB2:
                    answer = PrimitiveCombination2.Make((Hunk3)arg1);
                    break;

                case TC.PRIMITIVE:
                    if (!(arg1 is PrimitiveCombination0))
                    {
                        throw new NotImplementedException("Object-set-type on primitive");
                    }
                    answer = ((PrimitiveCombination0)arg1).Operator;
                    break;

                case TC.RECORD:
                    answer = new Record((object [])arg1);
                    return(false);

                case TC.SEQUENCE_3:
                    answer = new Sequence3((Hunk3)arg1);
                    break;

                case TC.THE_ENVIRONMENT:
                    answer = TheEnvironment.Make();
                    break;

                case TC.VARIABLE:
                    answer = Variable.Make((Hunk3)arg1);
                    break;

                case TC.VECTOR:
                    // Someone wants to see what endian we are!
                    char []   source = (char [])arg1;
                    object [] result = new object [source.Length / 4];
                    result [1] = ((((((byte)source [3]) * 256)
                                    + ((byte)source [2])) * 256)
                                  + ((byte)source [1])) * 256
                                 + ((byte)source [0]);
                    result [0] = ((((((byte)source [7]) * 256)
                                    + ((byte)source [6])) * 256)
                                  + ((byte)source [5])) * 256
                                 + ((byte)source [4]);
                    answer = result;
                    break;

                case TC.WEAK_CONS:
                    answer = new WeakCons(((Cons)arg1).Car, ((Cons)arg1).Cdr);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            return(false);
        }