Exemplo n.º 1
0
        protected override IPyValue VisitMethodExpression(MethodExpression src)
        {
            if (src.Method.IsStatic)
            {
                var pyClassName =
                    _state.Principles.GetPyType(src.Method.DeclaringType, true, _state.Principles.CurrentType);
                if (pyClassName.IsEmpty)
                {
                    throw new Exception("PyClassName cannot be null");
                }
                pyClassName = pyClassName.MakeAbsolute();
                var className             = new PyConstValue(pyClassName.FullName);
                var methodTranslationInfo = _state.Principles.GetOrMakeTranslationInfo(src.Method);
                if (!src.Method.IsPublic)
                {
                    WriteWarning(string.Format("Using not public method {0}.{1} as expression",
                                               src.Method.DeclaringType, src.Method.Name));
                }
                var methodName    = new PyConstValue(methodTranslationInfo.ScriptName);
                var arrayCreation = new PyArrayCreateExpression(className, methodName);
                return(SimplifyPyExpression(arrayCreation));
            }

            {
                // ryzykuję z this
                var targetObject          = new PyThisExpression();
                var methodTranslationInfo = _state.Principles.GetOrMakeTranslationInfo(src.Method);
                var methodName            = new PyConstValue(methodTranslationInfo.ScriptName);
                var arrayCreation         = new PyArrayCreateExpression(targetObject, methodName);
                return(SimplifyPyExpression(arrayCreation));
            }
        }
Exemplo n.º 2
0
 protected virtual T VisitPyThisExpression(PyThisExpression node)
 {
     if (ThrowNotImplementedException)
     {
         throw new NotImplementedException(string.Format("Method {0} is not supported in class {1}", "VisitPyThisExpression", this.GetType().FullName));
     }
     return(default(T));
 }