private string BuildExternSignature(TypeSymbol containingType, string methodName)
        {
            Type methodSourceType = containingType.UdonType.SystemType;

            methodSourceType = UdonSharpUtils.RemapBaseType(methodSourceType);

            string functionNamespace = CompilerUdonInterface.SanitizeTypeName(methodSourceType.FullName ?? methodSourceType.Namespace + methodSourceType.Name).Replace("VRCUdonUdonBehaviour", "VRCUdonCommonInterfacesIUdonEventReceiver");

            methodName = $"__{methodName}";
            var parameters = Parameters;

            string paramStr = "";

            if (parameters.Length > 0)
            {
                paramStr = "_"; // Arg separator

                foreach (ParameterSymbol parameter in parameters)
                {
                    paramStr += $"_{CompilerUdonInterface.GetUdonTypeName(parameter.Type)}";
                }
            }
            else if (IsConstructor)
            {
                paramStr = "__";
            }

            string returnStr;

            if (!IsConstructor)
            {
                returnStr = ReturnType != null ? $"__{CompilerUdonInterface.GetUdonTypeName(ReturnType)}" : "__SystemVoid";
            }
            else
            {
                returnStr = $"__{CompilerUdonInterface.GetUdonTypeName(containingType)}";
            }

            string finalFunctionSig = $"{functionNamespace}.{methodName}{paramStr}{returnStr}";

            return(finalFunctionSig);
        }
Exemple #2
0
        private string GetSignature(AbstractPhaseContext context)
        {
            System.Type methodSourceType = ContainingType.UdonType.SystemType;

            methodSourceType = UdonSharpUtils.RemapBaseType(methodSourceType);

            if (methodSourceType == typeof(string) &&
                (Parameters[0].Type.UdonType.SystemType == typeof(object) ||
                 Parameters[1].Type.UdonType.SystemType == typeof(object)))
            {
                return("SystemString.__Concat__SystemObject_SystemObject__SystemString");
            }

            string functionNamespace = CompilerUdonInterface.SanitizeTypeName(methodSourceType.FullName ??
                                                                              methodSourceType.Namespace + methodSourceType.Name);

            string methodName = $"__{GetOperatorUdonName().Trim('_').TrimStart('.')}";
            var    parameters = RoslynSymbol.Parameters;

            string paramStr = "_";                                                                                  // Arg separator

            if (parameters.Length > 1 || methodName.Contains("UnaryMinus") || methodName.Contains("UnaryNegation")) // Binary operators
            {
                foreach (IParameterSymbol parameter in parameters)
                {
                    paramStr +=
                        $"_{CompilerUdonInterface.GetUdonTypeName(context.GetTypeSymbol(parameter.Type))}";
                }
            }
            else // Unary operators, we just use the regular binary operator internally and handle it in the bound operator
            {
                paramStr += $"_{CompilerUdonInterface.GetUdonTypeName(context.GetTypeSymbol(parameters[0].Type))}";
                paramStr += $"_{CompilerUdonInterface.GetUdonTypeName(context.GetTypeSymbol(parameters[0].Type))}";
            }

            string returnStr =
                $"__{CompilerUdonInterface.GetUdonTypeName(ReturnType)}";

            return($"{functionNamespace}.{methodName}{paramStr}{returnStr}");
        }
Exemple #3
0
        private List <System.Type> GetTypeArgumentList(TypeArgumentListSyntax typeArgumentList)
        {
            UpdateSyntaxNode(typeArgumentList);

            List <System.Type> argumentTypes = new List <System.Type>();

            foreach (TypeSyntax typeSyntax in typeArgumentList.Arguments)
            {
                using (ExpressionCaptureScope typeCaptureScope = new ExpressionCaptureScope(visitorContext, null))
                {
                    Visit(typeSyntax);

                    if (!typeCaptureScope.IsType())
                    {
                        throw new System.ArgumentException("Generic argument must be a valid type");
                    }

                    argumentTypes.Add(UdonSharpUtils.RemapBaseType(typeCaptureScope.captureType));
                }
            }

            return(argumentTypes);
        }