Inheritance: AbstractLocalEntity, IParameter, ILocalEntity, IInternalEntity
示例#1
0
 public ReferenceExpression CreateReference(InternalParameter parameter)
 {
     return(new ReferenceExpression(parameter.Name)
     {
         Entity = parameter,
         ExpressionType = parameter.Type
     });
 }
示例#2
0
        public ReferenceExpression CreateReference(InternalParameter parameter)
        {
            ReferenceExpression reference = new ReferenceExpression(parameter.Name);

            reference.Entity         = parameter;
            reference.ExpressionType = parameter.Type;
            return(reference);
        }
示例#3
0
        public override void LeaveCallableTypeReference(CallableTypeReference node)
        {
            IParameter[] parameters = new IParameter[node.Parameters.Count];
            for (int i=0; i<parameters.Length; ++i)
            {
                parameters[i] = new InternalParameter(node.Parameters[i], i);
            }

            IType returnType = null;
            if (null != node.ReturnType)
            {
                returnType = GetType(node.ReturnType);
            }
            else
            {
                returnType = TypeSystemServices.VoidType;
            }

            node.Entity = TypeSystemServices.GetConcreteCallableType(node, new CallableSignature(parameters, returnType));
        }
示例#4
0
        private CallableSignature CallableSignatureFor(CallableTypeReference node)
        {
            var parameters = new IParameter[node.Parameters.Count];
            for (int i=0; i<parameters.Length; ++i)
                parameters[i] = new InternalParameter(node.Parameters[i], i);

            var returnType = node.ReturnType != null
                   ? GetType(node.ReturnType)
                   : TypeSystemServices.VoidType;

            return new CallableSignature(parameters, returnType, node.Parameters.HasParamArray);
        }
示例#5
0
        private void SetByRefParam(InternalParameter param, Expression right, bool leaveValueOnStack)
        {
            LocalBuilder temp = null;
            IType tempType = null;
            if (leaveValueOnStack)
            {
                Visit(right);
                tempType = PopType();
                temp = StoreTempLocal(tempType);
            }

            LoadParam(param);
            if (temp != null)
            {
                LoadLocal(temp, tempType);
            }
            else
            {
                Visit(right);
            }

            EmitCastIfNeeded(param.Type, PopType());

            OpCode storecode = GetStoreRefParamCode(param.Type);
            if (IsStobj(storecode)) //passing struct/decimal byref
            {
                _il.Emit(storecode, GetSystemType(param.Type));
            }
            else
            {
                _il.Emit(storecode);
            }

            if (null != temp)
            {
                LoadLocal(temp, tempType);
            }
        }
示例#6
0
        void LoadParam(InternalParameter param)
        {
            int index = param.Index;

            switch (index)
            {
                case 0:
                    {
                        _il.Emit(OpCodes.Ldarg_0);
                        break;
                    }

                case 1:
                    {
                        _il.Emit(OpCodes.Ldarg_1);
                        break;
                    }

                case 2:
                    {
                        _il.Emit(OpCodes.Ldarg_2);
                        break;
                    }

                case 3:
                    {
                        _il.Emit(OpCodes.Ldarg_3);
                        break;
                    }

                default:
                    {
                        if (index < 256)
                        {
                            _il.Emit(OpCodes.Ldarg_S, index);
                        }
                        else
                        {
                            _il.Emit(OpCodes.Ldarg, index);
                        }
                        break;
                    }
            }
        }
示例#7
0
 public ReferenceExpression CreateReference(InternalParameter parameter)
 {
     ReferenceExpression reference = new ReferenceExpression(parameter.Name);
     reference.Entity = parameter;
     reference.ExpressionType = parameter.Type;
     return reference;
 }