Beispiel #1
0
 public ResultStatus GetActions(
     Closes closes,
     Closes_Request request,
     out Closes_Result result)
 {
     return(this.GetActions(closes, (Closes_Parameters)null, request, out result));
 }
Beispiel #2
0
        internal void EmitLocal(CljILGen ilg, LocalBinding lb)
        {
            Type primType = lb.PrimitiveType;

            if (Closes.containsKey(lb))
            {
                ilg.Emit(OpCodes.Ldarg_0); // this
                FieldBuilder fb = ClosedOverFieldsMap[lb];
                ilg.MaybeEmitVolatileOp(IsVolatile(lb));
                ilg.Emit(OpCodes.Ldfld, fb);
                if (primType != null)
                    HostExpr.EmitBoxReturn(this, ilg, primType);
                // TODO: ONCEONLY?
            }
            else
            {
                if (lb.IsArg)
                {
                    //int argOffset = IsStatic ? 1 : 0;
                    //ilg.Emit(OpCodes.Ldarg, lb.Index - argOffset);
                    ilg.EmitLoadArg(lb.Index);
                }
                else if (lb.IsThis)
                {
                    ilg.EmitLoadArg(0);
                }
                else
                {
                    ilg.Emit(OpCodes.Ldloc, lb.LocalVar);
                }
                if (primType != null)
                    HostExpr.EmitBoxReturn(this, ilg, primType);
            }
        }
Beispiel #3
0
 public ResultStatus CreateParametricData(
     Closes closes,
     Closes_Request request,
     out Closes_Result result)
 {
     return(this.CreateParametricData(closes, (Closes_Parameters)null, request, out result));
 }
Beispiel #4
0
 public ResultStatus ProcessComputation(
     Closes closes,
     Closes_Request request,
     out Closes_Result result)
 {
     return(this.ProcessComputation(closes, (Closes_Parameters)null, request, out result));
 }
Beispiel #5
0
 public ResultStatus LoadESigDetails(
     Closes closes,
     Closes_Request request,
     out Closes_Result result)
 {
     return(this.LoadESigDetails(closes, (Closes_LoadESigDetails_Parameters)null, request, out result));
 }
Beispiel #6
0
        void EmitClosedOverFields(TypeBuilder tb)
        {
            _closedOverFields    = new List <FieldBuilder>(Closes.count());
            _closedOverFieldsMap = new Dictionary <LocalBinding, FieldBuilder>(Closes.count());

            // closed-overs map to instance fields.
            for (ISeq s = RT.keys(Closes); s != null; s = s.next())
            {
                LocalBinding lb = (LocalBinding)s.first();

                FieldAttributes attributes   = FieldAttributes.Public;
                bool            markVolatile = IsVolatile(lb);

                if (IsDefType)
                {
                    if (!IsMutable(lb))
                    {
                        attributes |= FieldAttributes.InitOnly;
                    }
                }

                Type type = lb.PrimitiveType ?? typeof(object);

                FieldBuilder fb = markVolatile
                    ? tb.DefineField(lb.Name, type, new Type[] { typeof(IsVolatile) }, Type.EmptyTypes, attributes)
                    : tb.DefineField(lb.Name, type, attributes);

                GenInterface.SetCustomAttributes(fb, GenInterface.ExtractAttributes(RT.meta(lb.Symbol)));

                _closedOverFields.Add(fb);
                _closedOverFieldsMap[lb] = fb;
            }
        }
Beispiel #7
0
 public ResultStatus GetEnvironment(
     Closes cdo,
     Closes_Request request,
     out Closes_Result result)
 {
     result = (Closes_Result)null;
     try
     {
         return(((IClosesService)this._Channel).GetEnvironment(this._UserProfile, cdo, request, out result));
     }
     catch (Exception ex)
     {
         return(this.OnThrowException(ex));
     }
 }
Beispiel #8
0
        internal void EmitLocal(CljILGen ilg, LocalBinding lb)
        {
            Type primType = lb.PrimitiveType;

            if (Closes.containsKey(lb))
            {
                if (_fnMode == FnMode.Full)
                {
                    ilg.Emit(OpCodes.Ldarg_0); // this
                    ilg.Emit(OpCodes.Ldfld, _closedOverFieldsMap[lb]);
                    if (primType != null)
                    {
                        HostExpr.EmitBoxReturn(this, ilg, primType);
                    }
                    // TODO: ONCEONLY?
                }
                else // FnMode.Light
                {
                    ilg.Emit(OpCodes.Ldarg_0); // this
                    ilg.Emit(OpCodes.Castclass, typeof(IFnClosure));
                    ilg.EmitCall(Compiler.Method_IFnClosure_GetClosure);
                    ilg.EmitFieldGet(Compiler.Field_Closure_Locals);
                    ilg.EmitInt(lb.Index);
                    ilg.EmitLoadElement(typeof(Object));
                }
            }
            else
            {
                if (lb.IsArg)
                {
                    //int argOffset = IsStatic ? 1 : 0;
                    //ilg.Emit(OpCodes.Ldarg, lb.Index - argOffset);
                    ilg.EmitLoadArg(lb.Index);
                }
                else if (lb.IsThis)
                {
                    ilg.EmitLoadArg(0);
                }
                else
                {
                    ilg.Emit(OpCodes.Ldloc, lb.LocalVar);
                }
                if (primType != null)
                {
                    HostExpr.EmitBoxReturn(this, ilg, primType);
                }
            }
        }
Beispiel #9
0
        internal Type[] CtorTypes()
        {
            int i = !SupportsMeta ? 0 : 1;

            Type[] ret = new Type[Closes.count() + i];

            if (SupportsMeta)
                ret[0] = typeof(IPersistentMap);

            for (ISeq s = RT.keys(Closes); s != null; s = s.next(), i++)
            {
                LocalBinding lb = (LocalBinding)s.first();
                ret[i] = lb.PrimitiveType ?? typeof(object);
            }
            return ret;
        }
Beispiel #10
0
        public ResultStatus AddDataTransaction(Closes cdo)
        {
            this.OnBeforeCall(nameof(AddDataTransaction), (DCObject)cdo, (Parameters)null, (Request)null);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? this.GetAddDataTransactionException() : this.AddMethod((Method) new ClosesMethod(cdo, ClosesMethods.AddDataTransaction, (Closes_Parameters)null));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                Result result;
                this.OnAfterCall(nameof(AddDataTransaction), res, (DCObject)cdo, (Parameters)null, (Request)null, result);
            }
            return(res);
        }
Beispiel #11
0
 internal void EmitUnboxedLocal(CljILGen ilg, LocalBinding lb)
 {
     if (Closes.containsKey(lb))
     {
         ilg.Emit(OpCodes.Ldarg_0); // this
         FieldBuilder fb = ClosedOverFieldsMap[lb];
         ilg.MaybeEmitVolatileOp(IsVolatile(lb));
         ilg.Emit(OpCodes.Ldfld, fb);
     }
     else if (lb.IsArg)
     {
         //int argOffset = IsStatic ? 0 : 1;
         //ilg.Emit(OpCodes.Ldarg, lb.Index + argOffset);
         ilg.EmitLoadArg(lb.Index);
     }
     else if (lb.IsThis)
     {
         ilg.EmitLoadArg(0);
     }
     else
         ilg.Emit(OpCodes.Ldloc, lb.LocalVar);
 }
Beispiel #12
0
 internal void EmitUnboxedLocal(CljILGen ilg, LocalBinding lb)
 {
     if (Closes.containsKey(lb))
     {
         if (_fnMode == FnMode.Full)
         {
             ilg.Emit(OpCodes.Ldarg_0); // this
             ilg.Emit(OpCodes.Ldfld, _closedOverFieldsMap[lb]);
         }
         else
         {
             ilg.Emit(OpCodes.Ldarg_0); // this
             ilg.Emit(OpCodes.Castclass, typeof(IFnClosure));
             ilg.EmitCall(Compiler.Method_IFnClosure_GetClosure);
             ilg.EmitFieldGet(Compiler.Field_Closure_Locals);
             ilg.EmitInt(lb.Index);
             ilg.EmitLoadElement(typeof(Object));
             if (lb.PrimitiveType != null)
             {
                 ilg.Emit(OpCodes.Unbox, lb.PrimitiveType);
             }
         }
     }
     else if (lb.IsArg)
     {
         //int argOffset = IsStatic ? 0 : 1;
         //ilg.Emit(OpCodes.Ldarg, lb.Index + argOffset);
         ilg.EmitLoadArg(lb.Index);
     }
     else if (lb.IsThis)
     {
         ilg.EmitLoadArg(0);
     }
     else
     {
         ilg.Emit(OpCodes.Ldloc, lb.LocalVar);
     }
 }
Beispiel #13
0
        public ResultStatus ExecuteTransaction(
            Closes cdo,
            Closes_Request request,
            out Closes_Result result)
        {
            result = (Closes_Result)null;
            this.OnBeforeCall(nameof(ExecuteTransaction), (DCObject)cdo, (Parameters)null, (Request)request);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? ((IClosesService)this._Channel).ExecuteTransaction(this._UserProfile, cdo, request, out result) : this.AddMethod((Method) new ClosesMethod(cdo, ClosesMethods.ExecuteTransaction, (Closes_Parameters)null));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                this.OnAfterCall(nameof(ExecuteTransaction), res, (DCObject)cdo, (Parameters)null, (Request)request, (Result)result);
            }
            return(res);
        }
Beispiel #14
0
        public ResultStatus ResolveParametricData(
            Closes closes,
            Closes_Parameters parameters,
            Closes_Request request,
            out Closes_Result result)
        {
            result = (Closes_Result)null;
            this.OnBeforeCall(nameof(ResolveParametricData), (DCObject)closes, (Parameters)parameters, (Request)request);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? ((IClosesService)this._Channel).ResolveParametricData(this._UserProfile, closes, parameters, request, out result) : this.AddMethod((Method) new ClosesMethod(closes, ClosesMethods.ResolveParametricData, parameters));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                this.OnAfterCall(nameof(ResolveParametricData), res, (DCObject)closes, (Parameters)parameters, (Request)request, (Result)result);
            }
            return(res);
        }
Beispiel #15
0
        void LightEmit(RHC rhc, ObjExpr objx, CljILGen ilg)
        {
            //emitting a Fn means constructing an instance, feeding closed-overs from enclosing scope, if any
            //objx arg is enclosing objx, not this


            // Create the function instance
            LocalBuilder fnLocal = ilg.DeclareLocal(CompiledType);

            if (CompiledType == typeof(RestFnImpl))
            {
                ilg.EmitInt(_variadicMethod.RequiredArity);
                ilg.EmitNew(Compiler.Ctor_RestFnImpl_1);
            }
            else
            {
                ilg.EmitNew(Compiler.Ctor_AFnImpl);
            }

            ilg.Emit(OpCodes.Stloc, fnLocal);

            //ilg.EmitString(String.Format("Creating fn {0}", Name));
            //ilg.Emit(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine", new Type[] { typeof(string) }));

            // Set up the methods

            for (ISeq s = RT.seq(_methods); s != null; s = s.next())
            {
                FnMethod method = (FnMethod)s.first();
                int      key    = GetMethodKey(method);

                string fieldName = IsVariadic && method.IsVariadic
                    ? "_fnDo" + (key - 1)  // because key is arity+1 for variadic
                    : "_fn" + key;

                FieldInfo fi = CompiledType.GetField(fieldName);

                ilg.Emit(OpCodes.Ldloc, fnLocal);


                EmitGetDynMethod(key, ilg);
                ilg.EmitType(fi.FieldType);
                ilg.Emit(OpCodes.Ldloc, fnLocal);
                ilg.Emit(OpCodes.Callvirt, Method_DynamicMethod_CreateDelegate);
                ilg.Emit(OpCodes.Castclass, fi.FieldType);

                ilg.EmitFieldSet(fi);
            }



            // setup the constants and locals
            ilg.Emit(OpCodes.Ldloc, fnLocal);

            if (Constants.count() > 0)
            {
                EmitGetCompiledConstants(ilg);
            }
            else
            {
                ilg.EmitInt(0);
                ilg.EmitArray(typeof(Object[]));
            }

            if (Closes.count() > 0)
            {
                int maxIndex = Closes.Max(c => ((LocalBinding)c.key()).Index);

                ilg.EmitInt(maxIndex + 1);
                ilg.Emit(OpCodes.Newarr, typeof(object));

                for (ISeq s = RT.keys(Closes); s != null; s = s.next())
                {
                    LocalBinding lb = (LocalBinding)s.first();
                    ilg.Emit(OpCodes.Dup);
                    ilg.EmitInt(lb.Index);
                    objx.EmitLocal(ilg, lb);
                    ilg.EmitStoreElement(typeof(object));
                }
            }
            else
            {
                ilg.EmitInt(0);
                ilg.EmitArray(typeof(Object[]));
            }

            // Create the closure
            ilg.EmitNew(Compiler.Ctor_Closure_2);

            // Assign the clojure
            ilg.EmitCall(Compiler.Method_IFnClosure_SetClosure);

            // Leave the instance on the stack.
            ilg.Emit(OpCodes.Ldloc, fnLocal);
        }
Beispiel #16
0
 public ResultStatus LoadESigDetails(Closes closes)
 {
     return(this.LoadESigDetails(closes, (Closes_LoadESigDetails_Parameters)null, (Closes_Request)null, out Closes_Result _));
 }
Beispiel #17
0
 public ResultStatus ProcessComputation(Closes closes)
 {
     return(this.ProcessComputation(closes, (Closes_Parameters)null, (Closes_Request)null, out Closes_Result _));
 }
Beispiel #18
0
 public ResultStatus CreateParametricData(Closes closes)
 {
     return(this.CreateParametricData(closes, (Closes_Parameters)null, (Closes_Request)null, out Closes_Result _));
 }
Beispiel #19
0
 public ClosesMethod(Closes Cdo, ClosesMethods Method, Closes_Parameters Parameters)
 {
     this.Cdo           = Cdo;
     this.ServiceMethod = Method;
     this.Parameters    = Parameters;
 }
Beispiel #20
0
 public ResultStatus ExecuteTransaction(Closes cdo)
 {
     return(this.ExecuteTransaction(cdo, (Closes_Request)null, out Closes_Result _));
 }
Beispiel #21
0
 public ResultStatus GetActions(Closes closes)
 {
     return(this.GetActions(closes, (Closes_Parameters)null, (Closes_Request)null, out Closes_Result _));
 }