! 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 ;
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." } ;
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 ;
] 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 ] [
[ 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
] 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