Example #1
0
        private void FillVars(List <ILVariable> vars)
        {
            if (thisMethod.HasThis)
            {
                var2Index.Add(vars.Where(V => V.Name == "this").FirstOrDefault() ?? new ILVariable()
                {
                    Name = "this"
                },
                              nextVarIndex++);
            }
            for (int i = 0; i < thisMethod.Parameters.Count; i++)
            {
                InterParameter param = thisMethod.Parameters[i];
                ILVariable     var   = vars.Where(V => ((V.IsParameter) && (V.OriginalParameter.Index == param.Index))).FirstOrDefault();
                var2Index.Add(var, nextVarIndex++);

                if (param.Type.IsPrimitive)
                {
                    JavaPrimitiveType varType = JavaHelpers.PrimitiveTypeToJavaPrimitive(param.Type.PrimitiveType);

                    if ((varType == JavaPrimitiveType.Long) || (varType == JavaPrimitiveType.Double))
                    {
                        nextVarIndex++;
                    }
                }
            }

            if (thisMethod.IsVarArg)
            {
                var2Index.Add(new ILVariable()
                {
                    Name = ClassNames.VarArgParamName
                }, nextVarIndex++);
            }
        }
Example #2
0
        private int GetVarIndex(ILVariable var)
        {
            if (var2Index.ContainsKey(var))
            {
                return(var2Index[var]);
            }

            int result = nextVarIndex++;

            var2Index.Add(var, result);

            InterType varType = resolver.Resolve(var.Type, thisMethod.FullGenericArguments);

            if (varType.IsPrimitive)
            {
                JavaPrimitiveType javaPrimitiv = JavaHelpers.PrimitiveTypeToJavaPrimitive(varType.PrimitiveType);
                if ((javaPrimitiv == JavaPrimitiveType.Long) || (javaPrimitiv == JavaPrimitiveType.Double))
                {
                    nextVarIndex++;
                }
            }
            else if (varType.IsValueType)
            {
                valueTypesVars.Add(new ValueTypeVar(varType, result));
            }


            return(result);
        }
Example #3
0
        private string GetFieldDescriptor(InterType type)
        {
            StringBuilder result = new StringBuilder();

            if ((type.IsByRef) && (type.ElementType.IsValueType))
            {
                type = type.ElementType;
            }

            if (type.IsArray)
            {
                result
                .Append('[', type.ArrayRank)
                .Append(GetFieldDescriptor(type.ElementType));
            }
            else if (type.IsByRef)
            {
                result
                .Append('L')
                .Append(TypeNameToJava(GetByRefTypeName(type)))
                .Append(';');
            }
            else if (type.IsEnum)
            {
                return(GetFieldDescriptor(type.ElementType));
            }
            else if (type.IsPrimitive)
            {
                result.Append(JavaPrimitive2FieldChar[(int)JavaHelpers.PrimitiveTypeToJavaPrimitive(type.PrimitiveType)]);
            }
            else
            {
                result
                .Append('L')
                .Append(TypeNameToJava(type.Fullname))
                .Append(';');
            }

            return(result.ToString());
        }