From 944caf84ede14c9915c657dcfb61f1fbc1ff0cdb Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 10 Jan 2016 13:51:04 +0000 Subject: [PATCH] src/: Write `NULL' for a null pointer, rather than plain `0'. This isn't my usual style, but others may like it more. The output is controlled by a new variable `*null-pointer*'. Maybe it will be configurable later. --- doc/SYMBOLS | 1 + doc/clang.tex | 3 ++- src/codegen-proto.lisp | 3 +++ src/method-impl.lisp | 2 +- src/method-proto.lisp | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/SYMBOLS b/doc/SYMBOLS index 5ee51b3..bb6b944 100644 --- a/doc/SYMBOLS +++ b/doc/SYMBOLS @@ -326,6 +326,7 @@ codegen-impl.lisp temporary-variable class codegen-proto.lisp + *null-pointer* variable *sod-ap* variable *sod-master-ap* variable block-inst class diff --git a/doc/clang.tex b/doc/clang.tex index f5b16a8..9da2f36 100644 --- a/doc/clang.tex +++ b/doc/clang.tex @@ -859,7 +859,8 @@ Temporary names are represented by objects which implement a simple protocol. \begin{tabular}[C]{*2{>{\codeface}l}} \hlx*{hv} \thd{\textbf{Variable}} & \thd{\textbf{Name format}} \\ \hlx{vhv} {}*sod-ap* & sod__ap \\ - {}*sod-master-ap* & sod__master_ap \\ \hlx*{vh} + {}*sod-master-ap* & sod__master_ap \\ + {}*null-pointer* & NULL \\ \hlx*{vh} \end{tabular} \caption{Well-known temporary names} \label{tab:codegen.codegen.well-known-temps} diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index 4bfaeca..c115671 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -67,6 +67,9 @@ (defparameter *sod-tmp-val* (make-instance 'temporary-name :tag "sod__t")) +(export '*null-pointer*) +(defparameter *null-pointer* "NULL") + ;;;-------------------------------------------------------------------------- ;;; Instructions. diff --git a/src/method-impl.lisp b/src/method-impl.lisp index 8501a02..e4aaae3 100644 --- a/src/method-impl.lisp +++ b/src/method-impl.lisp @@ -337,7 +337,7 @@ (sod-class-nickname message-class) (sod-message-name message) (sod-class-nickname chain-head)) - 0))) + *null-pointer*))) (defmethod method-entry-slot-name ((entry method-entry)) (let* ((method (method-entry-effective-method entry)) diff --git a/src/method-proto.lisp b/src/method-proto.lisp index 069f7e4..36237d6 100644 --- a/src/method-proto.lisp +++ b/src/method-proto.lisp @@ -407,7 +407,7 @@ (make-trampoline codegen (sod-method-class method) (lambda (target) (invoke chain target))) - 0)) + *null-pointer*)) (invoke (chain target) (if (null chain) (funcall kernel target) -- 2.11.0