/// <summary>
        /// エラーならnullを返す。
        /// </summary>
        public static UserDefinedMethodTerm Create(FunctionLabelLine targetLabel, IOperandTerm[] srcArgs, out string errMes)
        {
            CalledFunction call             = CalledFunction.CreateCalledFunctionMethod(targetLabel, targetLabel.LabelName);
            UserDefinedFunctionArgument arg = call.ConvertArg(srcArgs, out errMes);

            if (arg == null)
            {
                return(null);
            }
            return(new UserDefinedMethodTerm(arg, call.TopLabel.MethodType, call));
        }
示例#2
0
        /// <summary>
        ///     戻り値と引数の数・型の完全一致が必要
        /// </summary>
        /// <param name="call"></param>
        /// <returns>一致ならtrue</returns>
        internal bool MatchType(CalledFunction call)
        {
            var label = call.TopLabel;

            if (label.IsError)
            {
                return(false);
            }
            if (RetType != label.MethodType)
            {
                return(false);
            }
            if (ArgTypeList.Length != label.Arg.Length)
            {
                return(false);
            }
            for (var i = 0; i < ArgTypeList.Length; i++)
            {
                var vToken = label.Arg[i].Identifier;
                if (vToken.IsReference)
                {
                    var type = UserDifinedFunctionDataArgType.__Ref;
                    type += vToken.Dimension;
                    if (vToken.IsInteger)
                    {
                        type |= UserDifinedFunctionDataArgType.Int;
                    }
                    else
                    {
                        type |= UserDifinedFunctionDataArgType.Str;
                    }
                    if (ArgTypeList[i] != type)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (vToken.IsInteger && ArgTypeList[i] != UserDifinedFunctionDataArgType.Int)
                    {
                        return(false);
                    }
                    if (vToken.IsString && ArgTypeList[i] != UserDifinedFunctionDataArgType.Str)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#3
0
 private UserDefinedMethodTerm(UserDefinedFunctionArgument arg, Type returnType, CalledFunction call)
     : base(returnType)
 {
     Argument = arg;
     Call     = call;
 }
示例#4
0
 internal void SetReference(CalledFunction call)
 {
     CalledFunction = call;
 }
示例#5
0
 public RefArgument(UserDefinedRefMethod udrm, CalledFunction src)
 {
     RefMethodToken    = udrm;
     SrcCalledFunction = src;
 }