コード例 #1
0
        public ThisPointer(IScope scope, SourceToken token)
        {
            this.token = token;
            scopes.FunctionScope funcscope = scope as scopes.FunctionScope;

            if (funcscope != null)
            {
                if (!funcscope.function.IsAnonymous && funcscope.parentScope is scopes.ObjectInstanceScope)
                {
                    //refblockid = ((scopes.ObjectInstanceScope)funcscope.parentScope)._class.blockid;
                    valueType =
                        ((scopes.ObjectInstanceScope)scope.parentScope)._class.getRtType();
                }
                else if (!funcscope.function.IsAnonymous && funcscope.parentScope is scopes.FunctionScope)
                {
                    var tempscope = funcscope.parentScope;
                    while (tempscope is scopes.FunctionScope)
                    {
                        if (((scopes.FunctionScope)tempscope).function.IsAnonymous)
                        {
                            break;
                        }

                        tempscope = tempscope.parentScope;
                    }

                    if (tempscope is scopes.ObjectInstanceScope)
                    {
                        valueType =
                            ((scopes.ObjectInstanceScope)tempscope)._class.getRtType();
                    }
                    else
                    {
                        valueType = RunTimeDataType.rt_void;
                    }
                }
                else if (funcscope.parentScope is scopes.OutPackageMemberScope)
                {
                    //refblockid = ((scopes.OutPackageMemberScope)funcscope.parentScope).mainclass.outscopeblockid;
                    valueType = RunTimeDataType.rt_void;
                }
                else
                {
                    //refblockid = -1;//动态绑定
                    valueType = RunTimeDataType.rt_void;
                }
            }
            else
            {
                //refblockid = ((scopes.OutPackageMemberScope)scope).mainclass.outscopeblockid;
                valueType = RunTimeDataType.rt_void;
            }
        }