示例#1
0
        public override LuatValue Resolve(LuatScript script)
        {
            LuatValue value = base.Resolve(script);

            if (null != value)
            {
                return(value);
            }

            LuatValue lhsValue = LHS.Resolve(script);

            if (null == lhsValue)
            {
                return(null);
            }

            if (null == RHS)
            {
                return(null);
            }

            string index;

            if (false == GetString(RHS, out index))
            {
                return(null);
            }

            value = lhsValue.Index(index, IsLHSOfAssignment);
            if (null == value)
            {
                return(null);
            }

            this.ResolvedValues[script] = value;
            return(value);
        }
示例#2
0
        public override LuatValue Resolve(LuatScript script)
        {
            LuatValue value = base.Resolve(script);

            if (null != value)
            {
                return(value);
            }

            LuatValue funcValue = Owner.Resolve(script);

            if (null == funcValue)
            {
                return(null);
            }

            if (null != Name)
            {
                // funcValue isn't actually the function, but the owner.
                funcValue = funcValue.Index(Name.Text);
                if (null == funcValue)
                {
                    return(null);
                }
            }

            // Infer return type for value
            LuatFunction function = funcValue as LuatFunction;

            if (null == function)
            {
                LuatVariable variable = funcValue as LuatVariable;
                if (null != variable)
                {
                    foreach (LuatValue.IReference reference in variable.AssignmentsRecursive)
                    {
                        function = reference.Value as LuatFunction;

                        if (null != function)
                        {
                            break;
                        }
                    }
                }
            }

            if (null == function)
            {
                return(null);
            }

            if (function.ExpectsSelf != this.PassesSelf)
            {
                string warning = string.Format("Function expects to be called using '{0}' not '{1}'",
                                               function.ExpectsSelf ? ':' : '.',
                                               this.PassesSelf ? ':' : '.');
                AddWarning(script, WarningType.WrongFunctionCall, warning);
            }

            this.m_resolvedFunctions.Add(script, function);
            this.ResolvedValues[script] = function.ReturnValue;
            return(function);
        }