[Bese-devel] declarations
Larry D'Anna
smoof-ra at elder-gods.org
Mon Aug 15 20:31:06 UTC 2005
Here's another declarations patch. Now they have parent pointers and
are parsed into useful classes.
--larry
-------------- next part --------------
New patches:
[more usefull declaration objects
smoof-ra at elder-gods.org**20050815202603] {
hunk ./src/walk.lisp 141
-(defun split-body (body env &key (docstring t) (declare t))
+(defun split-body (body env &key parent (docstring t) (declare t))
hunk ./src/walk.lisp 143
- (decl nil)
+ (newdecls nil)
hunk ./src/walk.lisp 155
- (multiple-value-setf (env decl) (parse-declaration dec env))
- (when decl
- (push decl decls))))
+ (multiple-value-setf (env newdecls) (parse-declaration dec env parent))
+ (setf decls (append newdecls decls))))
hunk ./src/walk.lisp 180
-(defun parse-declaration (declaration environment)
- (macrolet ((extend-env ((var list) &rest datum)
- `(dolist (,var ,list)
- (setf environment (register environment :declare , at datum)))))
- (destructuring-bind (type &rest arguments)
- declaration
- (case type
- (dynamic-extent
- (extend-env (var arguments)
- var `(dynamic-extent)))
- (ftype
- (extend-env (function-name (cdr arguments))
- function-name `(ftype ,(first arguments))))
- (ignorable
- (extend-env (var arguments)
- var `(ignorable)))
- (ignore
- (extend-env (var arguments)
- var `(ignorable)))
- (inline
- (extend-env (function arguments) function `(ignorable)))
- (notinline
- (extend-env (function arguments) function `(notinline)))
- (optimize
- (extend-env (optimize-spec arguments) 'optimize optimize-spec))
- (special
- (extend-env (var arguments) var `(special)))
- (type
- (extend-env (var (rest arguments)) var `(type ,(first arguments))))
- (t
- (extend-env (var arguments) var `(type ,type))))))
- (values environment (make-instance 'declaration-form :source declaration)))
+(defclass optimize-declaration-form (declaration-form)
+ ((optimize-spec :accessor optimize-spec :initarg :optimize-spec)))
+
+(defclass variable-declaration-form (declaration-form)
+ ((name :accessor name :initarg :name)))
+
+(defclass function-declaration-form (declaration-form)
+ ((name :accessor name :initarg :name)))
+
+(defclass dynamic-extent-declaration-form (variable-declaration-form)
+ ())
+
+(defclass ignorable-declaration-form-mixin (declaration-form)
+ ())
+
+(defclass variable-ignorable-declaration-form (variable-declaration-form ignorable-declaration-form-mixin)
+ ())
+
+(defclass function-ignorable-declaration-form (function-declaration-form ignorable-declaration-form-mixin)
+ ())
+
+(defclass special-declaration-form (variable-declaration-form)
+ ())
+
+(defclass type-declaration-form (variable-declaration-form)
+ ((type-form :accessor type-form :initarg :type-form)))
+
+(defclass ftype-declaration-form (function-declaration-form)
+ ((type-form :accessor type-form :initarg :type-form)))
+
+(defclass notinline-declaration-form (function-declaration-form)
+ ())
+
+
+(defun parse-declaration (declaration environment parent)
+ (let ((declares nil))
+ (flet ((funname (form)
+ (if (and (consp form) (eql (car form) 'function))
+ (cadr form)
+ nil)))
+ (macrolet ((mkdecl (varname formclass &rest rest)
+ `(make-instance ,formclass :parent parent :source (list type ,varname) , at rest))
+ (extend-env ((var list) newdeclare &rest datum)
+ `(dolist (,var ,list)
+ (when ,newdeclare (push ,newdeclare declares))
+ (setf environment (register environment :declare , at datum)))))
+ (destructuring-bind (type &rest arguments)
+ declaration
+ (case type
+ (dynamic-extent
+ (extend-env (var arguments)
+ (mkdecl var 'variable-ignorable-declaration-form)
+ var `(dynamic-extent)))
+ (ftype
+ (extend-env (function-name (cdr arguments))
+ (make-instance 'ftype-declaration-form
+ :parent parent
+ :source `(ftype ,(first arguments) function-name)
+ :name function-name
+ :type-form (first arguments))
+ function-name `(ftype ,(first arguments))))
+ ((ignore ignorable)
+ (extend-env (var arguments)
+ (aif (funname var)
+ (mkdecl var 'function-ignorable-declaration-form :name it)
+ (mkdecl var 'variable-ignorable-declaration-form :name var))
+ var `(ignorable)))
+ (inline
+ (extend-env (function arguments)
+ (mkdecl function 'function-ignorable-declaration-form :name function)
+ function `(ignorable)))
+ (notinline
+ (extend-env (function arguments)
+ (mkdecl function 'notinline-declaration-form :name function)
+ function `(notinline)))
+ (optimize
+ (extend-env (optimize-spec arguments)
+ (mkdecl optimize-spec 'optimize-declaration-form :optimize-spec optimize-spec)
+ 'optimize optimize-spec))
+ (special
+ (extend-env (var arguments)
+ (mkdecl var 'special-declaration-form :name var)
+ var `(special)))
+ (type
+ (extend-env (var (rest arguments))
+ (make-instance 'type-declaration-form
+ :parent parent
+ :source `(type ,(first arguments) var)
+ :name var
+ :type-form (first arguments))
+ var `(type ,(first arguments))))
+ (t
+ (extend-env (var arguments)
+ (make-instance 'type-declaration-form
+ :parent parent
+ :source `(,type var)
+ :name var
+ :type-form type)
+ var `(type ,type)))))))
+ (when (null declares)
+ (setq declares (list (make-instance 'declaration-form :parent parent :source declaration))))
+ (values environment declares)))
hunk ./src/walk.lisp 285
- (split-body forms env :docstring docstring :declare declare)
+ (split-body forms env :parent parent :docstring docstring :declare declare)
}
Context:
[Change the name of the walker handler for atom so that it doesn't used to walk forms whose car is CL:ATOM.
Marco Baringer <mb at bese.it>**20050812114613]
[Added required specifier :primary to cc-standard method combination
Marco Baringer <mb at bese.it>**20050812114343
This prevents people from accidentaly using defmethod on a cc generic
function. You must now either use defmethod/cc (which retains the same
API as before), or pass the :primary method qualifier (and if you do
we'll assume you know what you're doing).
]
[Update the list of exported symbols
Marco Baringer <mb at bese.it>**20050812102709]
[Two minor indentation fixups
Marco Baringer <mb at bese.it>**20050812102429]
[Remove type declarations form join-string (ucw passes in strings which violate some of the type declarations)
Marco Baringer <mb at bese.it>**20050812102333]
[JOIN-STRINGS was not returning the result :(
Marco Baringer <mb at bese.it>**20050812070730]
[Added more tests for cc-standard method combination
Marco Baringer <mb at bese.it>**20050811152516]
[Make the arguments to a continuation all option (the equivalent of evaluating (values))
Marco Baringer <mb at bese.it>**20050811152449]
[Added cc definintions of common standard functions whcih take functions as parameters (assoc and mapXYZ)
Marco Baringer <mb at bese.it>**20050811152400]
[Added missing cleane-argument-list function and tests
Marco Baringer <mb at bese.it>**20050811130722]
[Fix generic/method/function lambda list handling and manipulation in walker and cc-interpreter
Marco Baringer <mb at bese.it>**20050811130002]
[Added support for &key, &allow-other-keys in lambda/cc (and therefore defun/cc and defmethod/cc)
Marco Baringer <mb at bese.it>**20050810140725]
[keyword-function-argument-form is not a subclass of optional-argument-form, even though they are superficially similar
Marco Baringer <mb at bese.it>**20050810140659]
[Move debugging code into DEFK where have access to the name of the continuation we're calling (as apposed to KLAMBDA)
Marco Baringer <mb at bese.it>**20050810121305]
[Refactor cc-interpreter into a few smaller files in the call-cc directory
Marco Baringer <mb at bese.it>**20050810104819]
[Refactor FOLD-STRING (Patch by: Janis Dzerins <jdz at dir.lv>)
Marco Baringer <mb at bese.it>**20050810103438]
[the fdefinition/cc table must remeber, other than the def, whether it was a function or a method (since we treat those two differently)
Marco Baringer <mb at bese.it>**20050810101541]
[Added :method-combination option to the expaniosn of the defgeneric/cc macro
Marco Baringer <mb at bese.it>**20050810101446]
[Added *debug-evaluate/cc* and related functions
Marco Baringer <mb at bese.it>**20050810063228]
[Use fedinition/cc, not fdefinition, for defun/cc
Marco Baringer <mb at bese.it>**20050810055126]
[Typo in name of k-for-apply/cc/optional-argument-default-value continuation
Marco Baringer <mb at bese.it>**20050810055105]
[Don't use GET so that we don't break package locks. Add now function fdefinition/cc
Marco Baringer <mb at bese.it>**20050810054327
Basically it's a bad idea to use #'get and #'(setf get) on standard
symbols, however this is something we're going to want to do. We know
have our own hash-table (*cc-functions*) which maps symbols to closure
objects.
]
[ method combination
smoof-ra at elder-gods.org**20050810035825]
[make closure/cc a funcallable instance (in sbcl)
smoof-ra at elder-gods.org**20050809182900
funcalling a closure/cc will just call it with a toplevel continuation
that way cc closures can be called totally transparently by non-cc code
as long as the cc-closure doesn't call/cc.
]
[Added copyright notice to cc-interpreter.lisp
Marco Baringer <mb at bese.it>**20050809151738]
[Remove occurences of 'cps' in the api. We don't actually cps transforme anymore so this is misleading.
Marco Baringer <mb at bese.it>**20050809125933]
[Remove 'cps' from test suite, replace it with 'call/cc'
Marco Baringer <mb at bese.it>**20050809104818]
[Rename cps.lisp to cc-interpreter.lisp
Marco Baringer <mb at bese.it>**20050809104737]
[Fix typo in fold-strings' docstring
Marco Baringer <mb at bese.it>**20050809083006]
[Trivial change to the name of the gensym generated by DOLIST*
Marco Baringer <mb at bese.it>**20050809061102]
[Fix lexical-variables and lexical-functions on clisp
Marco Baringer <mb at bese.it>**20050807223244]
[Use FDEFINITION instead of SYMBOL-FUNCTION to get a function from a function name.
Marco Baringer <mb at bese.it>**20050807222932]
[Make sure we only pass symbols to functions like GET and MACRO-FUNCTION
Marco Baringer <mb at bese.it>**20050807222905]
[Implement lexical-functions for CLISP
Marco Baringer <mb at bese.it>**20050807204738]
[Implement lexical-variables and lexical-functions for NIL environments
Marco Baringer <mb at bese.it>**20050807204711]
[Remove arnesi.el from ssytem def
Marco Baringer <mb at bese.it>**20050807204654]
[Fix evaluation of #'(foo bar) in cps interpreter
Marco Baringer <mb at bese.it>**20050806182653]
[Delete arnesi.el. SLIME is perfectly able to figure out the indententation by itself.
Marco Baringer <mb at bese.it>**20050807075500]
[aparently global variables can be found in sbcl lexical environments
smoof-ra at elder-gods.org**20050804164859]
[Implement environment-p and lexical-variables for CLISP
Marco Baringer <mb at bese.it>**20050804165821]
[Make the lexenv stuff use generic-functions and methods
Marco Baringer <mb at bese.it>**20050804161857]
[Fixup lexical-variables and lexical-functions for OpenMCL
Marco Baringer <mb at bese.it>**20050804152727
This patch causes lexical-variables to no longer return ignored
variables and symbol-macrolets. We've also implemented
lexical-functions (though we do some hackery to convert functions
names to something "normal" (ie SETF::|FOO::BAR| ==> (SETF FOO::BAR))
]
[Typo in lexical-variables for sbcl (we were accessing lexenv-funs instead of lexenv-vars)
Marco Baringer <mb at bese.it>**20050804152051]
[Change lexical-variables for sbcl so that it doesn't return ignored variables
Marco Baringer <mb at bese.it>**20050804150841]
[Fix lexical-variables for cmucl to not return ignored variables
Marco Baringer <mb at bese.it>**20050804150256]
[Typo in previous patch
Marco Baringer <mb at bese.it>**20050804150242]
[Implement lexical-functions for cmucl
Marco Baringer <mb at bese.it>**20050804143350]
[recognise flets from the lexical environment (on sbcl)
smoof-ra at elder-gods.org**20050803222732]
[Rewrite multiple-value-setf so that my simple mind can understand it.
Marco Baringer <mb at bese.it>**20050803104652]
[Added cps evaluation of THE forms
Marco Baringer <mb at bese.it>**20050803092059]
[minor comment fixup
Marco Baringer <mb at bese.it>**20050803085322]
[Moved defclass progv-form to keep the walker classes defined in alphabetical order
Marco Baringer <mb at bese.it>**20050803085254]
[Added walker class for THE forms
Marco Baringer <mb at bese.it>**20050803085210]
[allow new special forms to be added to the walker by shadowing *walker-handlers*
smoof-ra at elder-gods.org**20050802165355]
[Minor spacing fixs to the previous patch
Marco Baringer <mb at bese.it>**20050802152421]
[progv
smoof-ra at elder-gods.org**20050802150342]
[labels can have declarations inside the body
smoof-ra at elder-gods.org**20050801193433]
[declares needs to be copied in the labels handler just like the other lambda-function-form slots
smoof-ra at elder-gods.org**20050801193107]
[oops i forgot to actually make the declaration-form instances
smoof-ra at elder-gods.org**20050801185641]
[initial support for remembering declarations
smoof-ra at elder-gods.org**20050801184329
this patch adds a mixin called implicit-progn-with-declare-mixin and
uses it instead of implicit-progn-mixin in all the places that allow declares.
It has slot which should contain a list of the declares at the top of the
implicit-progn. This patch doesn't do anything clever with the declares,
it just creates declaration-form objects and points their source slots
at the original declares, however it would be easy to modify parse-declaration
to generate more usefull declaration objects.
]
[Call the property :FEATURES, not FEATURES
Marco Baringer <mb at bese.it>**20050729103229]
[Rename asdf property version to features, add "cps-interpreter"
Marco Baringer <mb at bese.it>**20050728120238]
[dont need to register allow-other-keys because its not a binding
smoof-ra at elder-gods.org**20050727153603]
[fixed type name mismatch for allow-other-keys-function-arguement-form
smoof-ra at elder-gods.org**20050727152456]
[defmethod arguments should be ignorable, not ignore (openmcl warns whenever you ignore a specialized argument)
Marco Baringer <mb at bese.it>**20050726090308]
[Typo in extract-argument-names
Marco Baringer <mb at bese.it>**20050726090256]
[Fix generation of defmethod froms from defmethod/cc; added tests
Marco Baringer <mb at bese.it>**20050726085226]
[Fix handling of optional arguments in apply-cps-lambda
Marco Baringer <mb at bese.it>**20050726085155]
[More tests
Marco Baringer <mb at bese.it>**20050723133158]
[Fix a bug in the handling of the case when LOOKUP finds a value for a name but the value is NIL
Marco Baringer <mb at bese.it>**20050723133106]
[Export the symbol KALL
Marco Baringer <mb at bese.it>**20050723133052]
[Change the test for constant-form'ness in walk.lisp
Marco Baringer <mb at bese.it>**20050723113019]
[Extend the walker to handle #'(setf foo) function names
Marco Baringer <mb at bese.it>**20050723104431]
[Fix bug in the lambda generated for method forms
Marco Baringer <mb at bese.it>**20050720144450]
[Added ignore declarations to defun/cc and defmethod/cc to make the compiler happy
Marco Baringer <mb at bese.it>**20050720110112]
[Temporarily comment out the log tests
Marco Baringer <mb at bese.it>**20050720092312]
[Rename (optional|keyword|rest)-argument-form classes to include the -form suffix
Marco Baringer <mb at bese.it>**20050720092124]
[Allow defun/cc defined functions te be called outside of a with-call/cc
Marco Baringer <mb at bese.it>**20050720091826]
[Added support for &optional arguments in cps closures
Marco Baringer <mb at bese.it>**20050720091658]
[Added defgeneric/cc
Marco Baringer <mb at bese.it>**20050719153441]
[Move the error checking code for lambda arguments into apply, not lambda (in cps interpreter)
Marco Baringer <mb at bese.it>**20050719153121]
[More cps tests
Marco Baringer <mb at bese.it>**20050719152327]
[Fix openmcl's definition of lexical-variables to deal with ccl::definition-environment
Marco Baringer <mb at bese.it>**20050719152230]
[Added support to the cps interpreter forl communicating with lexical variables
Marco Baringer <mb at bese.it>**20050707094608]
[walk.lisp depends on lexenv.lisp
Marco Baringer <mb at bese.it>**20050707093140]
[added support for walking local varibales in the lexical environment
Marco Baringer <mb at bese.it>**20050707093027
this applies to all those variables defined the envorinment object
grabbed via an &environment macro argument.
]
[mistyped #+openmcl in lexenv.lisp
Marco Baringer <mb at bese.it>**20050707092959]
[added src/lexenv.lisp to arnesi.asd
Marco Baringer <mb at bese.it>**20050707091127]
[Rename src/environment.lisp
Marco Baringer <mb at bese.it>**20050707091114]
[Initial version of environment.lisp
Marco Baringer <mb at bese.it>**20050707091019]
[Minor docstring fixup for with-call/cc
Marco Baringer <mb at bese.it>**20050707090619]
[Big patch including all the cps interpreter stuff upto now
Marco Baringer <mb at bese.it>**20050707083739]
[Fix bug in handling of defclass-struct's :predicate option
Marco Baringer <mb at bese.it>**20050706105324]
[Initial Import
Marco Baringer <mb at bese.it>**20050706101657
This import moves arnesi from arch to darcs. Nothing has actually changed since
bese-2004 at common-lisp.net/arnesi--dev--1.4--patch-14
]
[added arch stuff to boring file
Marco Baringer <mb at bese.it>**20050706101630]
[Setup boring file
Marco Baringer <mb at bese.it>**20050706100535]
Patch bundle hash:
5f28ccaa2a4bdc7b3974b3e4ad0762bdf6f6e9b6
More information about the bese-devel
mailing list