ALIEN: now reads a hexadecimal integer instead of a decimal one, since in general hex is more useful for addresses
parent
018677319c
commit
a2b864e4f5
|
@ -1,14 +1,15 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel combinators alien alien.strings alien.syntax
|
||||
prettyprint.backend prettyprint.custom prettyprint.sections ;
|
||||
math.parser prettyprint.backend prettyprint.custom
|
||||
prettyprint.sections ;
|
||||
IN: alien.prettyprint
|
||||
|
||||
M: alien pprint*
|
||||
{
|
||||
{ [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
|
||||
{ [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
|
||||
[ \ ALIEN: [ alien-address pprint* ] pprint-prefix ]
|
||||
[ \ ALIEN: [ alien-address >hex text ] pprint-prefix ]
|
||||
} cond ;
|
||||
|
||||
M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
|
||||
|
|
|
@ -9,7 +9,7 @@ HELP: DLL"
|
|||
|
||||
HELP: ALIEN:
|
||||
{ $syntax "ALIEN: address" }
|
||||
{ $values { "address" "a non-negative integer" } }
|
||||
{ $values { "address" "a non-negative hexadecimal integer" } }
|
||||
{ $description "Creates an alien object at parse time." }
|
||||
{ $notes "Alien objects are invalidated between image saves and loads, and hence source files should not contain alien literals; this word is for interactive use only. See " { $link "alien-expiry" } " for details." } ;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ IN: alien.syntax
|
|||
|
||||
SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
|
||||
|
||||
SYNTAX: ALIEN: scan string>number <alien> parsed ;
|
||||
SYNTAX: ALIEN: 16 scan-base <alien> parsed ;
|
||||
|
||||
SYNTAX: BAD-ALIEN <bad-alien> parsed ;
|
||||
|
||||
|
|
|
@ -472,15 +472,15 @@ cell 8 = [
|
|||
] unit-test
|
||||
|
||||
[ ALIEN: 123 ] [
|
||||
123 [ <alien> ] compile-call
|
||||
HEX: 123 [ <alien> ] compile-call
|
||||
] unit-test
|
||||
|
||||
[ ALIEN: 123 ] [
|
||||
123 [ { fixnum } declare <alien> ] compile-call
|
||||
HEX: 123 [ { fixnum } declare <alien> ] compile-call
|
||||
] unit-test
|
||||
|
||||
[ ALIEN: 123 ] [
|
||||
[ 123 <alien> ] compile-call
|
||||
[ HEX: 123 <alien> ] compile-call
|
||||
] unit-test
|
||||
|
||||
[ f ] [
|
||||
|
@ -522,8 +522,8 @@ cell 8 = [
|
|||
[ ALIEN: 1234 ALIEN: 2234 ] [
|
||||
ALIEN: 234 [
|
||||
{ c-ptr } declare
|
||||
[ 1000 swap <displaced-alien> ]
|
||||
[ 2000 swap <displaced-alien> ] bi
|
||||
[ HEX: 1000 swap <displaced-alien> ]
|
||||
[ HEX: 2000 swap <displaced-alien> ] bi
|
||||
] compile-call
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ cell 8 = [
|
|||
] unit-test
|
||||
] when
|
||||
|
||||
[ "ALIEN: 1234" ] [ 1234 <alien> unparse ] unit-test
|
||||
[ "ALIEN: 1234" ] [ HEX: 1234 <alien> unparse ] unit-test
|
||||
|
||||
[ ] [ 0 B{ 1 2 3 } <displaced-alien> drop ] unit-test
|
||||
|
||||
|
|
Loading…
Reference in New Issue