Skip to content
Browse files

some meta-functions implemented

  • Loading branch information...
1 parent b41c491 commit ea4896c94e599c219fed43d2fae4e87c525f476c @ilyasergey committed Oct 1, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 sources/fj.rkt
View
26 sources/fj.rkt
@@ -62,6 +62,32 @@ as described in Benjamin C. Pierce's "Types and Programming Languages"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Class lookup by name from the class table
+(define-metafunction FJ
+ class-lookup : CL C -> CL
+
+ [(class-lookup (CL CL_1 ...) C)
+ CL
+ (where (class C extends C_1((C_2 f) ...) K (M ...)) CL)]
+ [(class-lookup ((class C_1 extends C_2((C_3 f) ...) K (M ...)) CL_1 ...) C)
+ (class-lookup (CL_1 ...) C)])
+
+
+(define-metafunction FJ
+ fields : CT C -> ((C f) ...)
+
+ [(fields (CT Object)) ()]
+ [(fields (CT C))
+ ,(append (term (((C_2 f_2) ...) ((C_3 f_3) ...))))
+ (where (class C extends C_1((C_2 f_2) ...) K (M ...))
+ (class-lookup CT C))
+ (where ((C_3 f_3) ...)
+ (fields CT C_1))])
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Valid method overriding
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 comments on commit ea4896c

Please sign in to comment.
Something went wrong with that request. Please try again.