Esempio n. 1
0
 private void CloseOuters(OuterValue[] openOuters, uint newTop)
 {
     for (int i = openOuters.Length; --i >= newTop;)
         if (openOuters[i] != null)
         {
             openOuters[i].Close();
             openOuters[i] = null;
         }
 }
Esempio n. 2
0
        internal LayeClosure BuildClosure(FunctionPrototype proto, OuterValue[] openOuters, LayeTypeDef definedType, LayeObject[] defaults)
        {
            var top = stack.Top;
            var closure = new LayeClosure(top.closure.kit, proto, definedType, defaults);
            var protoOuters = proto.outers;

            for (var i = 0; i < protoOuters.Length; i++)
                if (protoOuters[i].type == OuterValueType.LOCAL)
                    closure.outers[i] = FindOuterValue(top.Locals, protoOuters[i].location, openOuters);
                else closure.outers[i] = top.closure.outers[protoOuters[i].location];

            return closure;
        }
Esempio n. 3
0
        private void EndCall(StackFrame frame, OuterValue[] openOuters)
        {
            // If we return early, make sure all things are gone plz
            // (this is me being lazy, we don't pop them automatically in the compiler)
            while (frame.activeExceptionHandlers > 0)
            {
                frame.activeExceptionHandlers--;
                exceptionHandlers.Pop();
            }

            if (openOuters != null)
                CloseOuters(openOuters, 0);
        }
Esempio n. 4
0
 private static OuterValue FindOuterValue(LayeObject[] locals, uint idx, OuterValue[] openOuters)
 {
     int n = openOuters.Length;
     for (int i = 0; i < n; i++)
         if (openOuters[i] != null && openOuters[i].Index == idx)
             return openOuters[i];
     for (int i = 0; i < n; i++)
         if (openOuters[i] == null)
             return openOuters[i] = new OuterValue(locals, idx);
     throw new ArgumentException("no space for new outer value.");
 }