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.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel combinators alien alien.strings alien.syntax
|
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
|
IN: alien.prettyprint
|
||||||
|
|
||||||
M: alien pprint*
|
M: alien pprint*
|
||||||
{
|
{
|
||||||
{ [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
|
{ [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
|
||||||
{ [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
|
{ [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
|
||||||
[ \ ALIEN: [ alien-address pprint* ] pprint-prefix ]
|
[ \ ALIEN: [ alien-address >hex text ] pprint-prefix ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
|
M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
|
||||||
|
|
|
@ -9,7 +9,7 @@ HELP: DLL"
|
||||||
|
|
||||||
HELP: ALIEN:
|
HELP: ALIEN:
|
||||||
{ $syntax "ALIEN: address" }
|
{ $syntax "ALIEN: address" }
|
||||||
{ $values { "address" "a non-negative integer" } }
|
{ $values { "address" "a non-negative hexadecimal integer" } }
|
||||||
{ $description "Creates an alien object at parse time." }
|
{ $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." } ;
|
{ $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: 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 ;
|
SYNTAX: BAD-ALIEN <bad-alien> parsed ;
|
||||||
|
|
||||||
|
|
|
@ -472,15 +472,15 @@ cell 8 = [
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ALIEN: 123 ] [
|
[ ALIEN: 123 ] [
|
||||||
123 [ <alien> ] compile-call
|
HEX: 123 [ <alien> ] compile-call
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ALIEN: 123 ] [
|
[ ALIEN: 123 ] [
|
||||||
123 [ { fixnum } declare <alien> ] compile-call
|
HEX: 123 [ { fixnum } declare <alien> ] compile-call
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ ALIEN: 123 ] [
|
[ ALIEN: 123 ] [
|
||||||
[ 123 <alien> ] compile-call
|
[ HEX: 123 <alien> ] compile-call
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ f ] [
|
[ f ] [
|
||||||
|
@ -522,8 +522,8 @@ cell 8 = [
|
||||||
[ ALIEN: 1234 ALIEN: 2234 ] [
|
[ ALIEN: 1234 ALIEN: 2234 ] [
|
||||||
ALIEN: 234 [
|
ALIEN: 234 [
|
||||||
{ c-ptr } declare
|
{ c-ptr } declare
|
||||||
[ 1000 swap <displaced-alien> ]
|
[ HEX: 1000 swap <displaced-alien> ]
|
||||||
[ 2000 swap <displaced-alien> ] bi
|
[ HEX: 2000 swap <displaced-alien> ] bi
|
||||||
] compile-call
|
] compile-call
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ cell 8 = [
|
||||||
] unit-test
|
] unit-test
|
||||||
] when
|
] 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
|
[ ] [ 0 B{ 1 2 3 } <displaced-alien> drop ] unit-test
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue