summaryrefslogtreecommitdiff
path: root/modules/language/python/compile.scm
diff options
context:
space:
mode:
authorStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-09-16 23:45:01 +0200
committerStefan Israelsson Tampe <stefan.itampe@gmail.com>2017-09-16 23:45:01 +0200
commit5dd3ccc81ba364569c072facacf0a6363de4b63f (patch)
tree029840962214ae30fe47b3b8566bfa1137c0d330 /modules/language/python/compile.scm
parent97a5352dbd778b693d9fe8c14bdde94d3b58da68 (diff)
slices now working
Diffstat (limited to 'modules/language/python/compile.scm')
-rw-r--r--modules/language/python/compile.scm33
1 files changed, 27 insertions, 6 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm
index 873b264..734fe60 100644
--- a/modules/language/python/compile.scm
+++ b/modules/language/python/compile.scm
@@ -50,12 +50,13 @@
x)
(define-inlinable (C x) `(@@ (language python compile) ,x))
-(define-inlinable (Y x) `(@@ (language python yield) ,x))
-(define-inlinable (T x) `(@@ (language python try) ,x))
-(define-inlinable (F x) `(@@ (language python for) ,x))
-(define-inlinable (L x) `(@@ (language python list) ,x))
-(define-inlinable (O x) `(@@ (oop pf-objects) ,x))
-(define-inlinable (G x) `(@ (guile) ,x))
+(define-inlinable (Y x) `(@@ (language python yield) ,x))
+(define-inlinable (T x) `(@@ (language python try) ,x))
+(define-inlinable (F x) `(@@ (language python for) ,x))
+(define-inlinable (L x) `(@@ (language python list) ,x))
+(define-inlinable (A x) `(@@ (language python array) ,x))
+(define-inlinable (O x) `(@@ (oop pf-objects) ,x))
+(define-inlinable (G x) `(@ (guile) ,x))
(define (union as vs)
(let lp ((as as) (vs vs))
@@ -293,6 +294,26 @@
trailer)
(lp `(,e ,@(map (g vs exp) args)) trailer)))
+ ((#:subscripts (n #f #f))
+ `(,(L 'pylist-ref) ,e ,(exp vs n)))
+
+ ((#:subscripts (n1 n2 n3))
+ (let ((w (lambda (x) (if (eq? x 'None) ''None x))))
+ `(,(L 'pylist-slice) ,e
+ ,(w (exp vs n1)) ,(w (exp vs n2)) ,(w (exp vs n3)))))
+
+ ((#:subscripts (n #f #f) ...)
+ `(,(A 'pyarray-ref) ,e (list ,@ (map (lambda (n)
+ (exp vs n))
+ n))))
+
+ ((#:subscripts (n1 n2 n3) ...)
+ (let ((w (lambda (x) (if (eq? x 'None) ''None x))))
+ `(,(A 'pyarray-slice) ,e
+ (list ,@(map (lambda (x y z)
+ `(list ,(exp vs x) ,(exp vs y) ,(exp vs z)))
+ n1 n2 n3)))))
+
(_ (error "unhandled trailer")))))))))))
(#:identifier