コード例 #1
0
ファイル: Block.cs プロジェクト: steven-r/Oberon0Compiler
#pragma warning disable CS3001 // Argument type is not CLS-compliant
        public FunctionDeclaration LookupFunction(string name, IToken token, string parameters)
#pragma warning restore CS3001 // Argument type is not CLS-compliant
        {
            var callParameters = CallParameter.CreateFromStringExpression(this, parameters);

            return(LookupFunction(name, token, callParameters));
        }
コード例 #2
0
        internal static IReadOnlyList <CallParameter> CreateFromStringExpression(
            [NotNull] Block block, string parameters = null)
        {
#if !DEBUG
            throw new InvalidOperationException("CreateFromStringExpression is only valid for test configurations");
#else
            if (block == null)
            {
                throw new ArgumentNullException(nameof(block));
            }

            var resultList = new List <CallParameter>();
            if (parameters == null)
            {
                return(resultList);
            }

            foreach (string element in parameters.Split(','))
            {
                var callParameter = new CallParameter();

                (var targetType, bool isVar) = Module.GetParameterDeclarationFromString(element, block);

                callParameter.CanBeVarReference = isVar;
                callParameter.TargetType        = targetType;
                callParameter.TypeName          = callParameter.TargetType.Name;

                resultList.Add(callParameter);
            }

            return(resultList);
#endif
        }
コード例 #3
0
ファイル: Block.cs プロジェクト: steven-r/Oberon0Compiler
        private static bool GenerateVarParameterCount(CallParameter callParameter, Declaration procedureParameter, ref int score)
        {
            if (callParameter.CanBeVarReference)
            {
                if (!procedureParameter.Type.Equals(callParameter.TargetType))
                {
                    // VAR parameter need to have the same type as calling parameter
                    return(false);
                }

                score += 1000;
            }
            else
            {
                // VAR parameter cannot have expression as source
                return(false);
            }

            return(true);
        }