1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
############################################################################
#
# File: internal.c
#
# Subject: Functions to access Icon internals
#
# Author: Gregg M. Townsend
#
# Date: October 3, 1995
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# These functions provide some access to the internal machinery of the
# Icon interpreter. Some knowledge of the interpreter is needed to use
# these profitably; misuse can lead to memory violations.
#
# dword(x) return d-word of descriptor
# vword(x) return v-word of descriptor
# descriptor(d,v) construct descriptor from d-word and v-word
# peek(addr,n) return contents of memory as n-character string
# (if n is omitted, return Icon integer at addr)
# spy(addr,n) return string pointer to memory, without copying
#
############################################################################
#
# Requires: Dynamic loading
#
############################################################################
*/
#include "icall.h"
int dword(int argc, descriptor argv[]) /*: return descriptor d-word */
{
if (argc == 0)
Fail;
else
RetInteger(argv[1].dword);
}
int vword(int argc, descriptor argv[]) /*: return descriptor v-word */
{
if (argc == 0)
Fail;
else
RetInteger(argv[1].vword);
}
int icon_descriptor(int argc, descriptor argv[]) /*: construct descriptor */
{
ArgInteger(1);
ArgInteger(2);
argv[0].dword = argv[1].vword;
argv[0].vword = argv[2].vword;
Return;
}
int peek(int argc, descriptor argv[]) /*: load value from memory */
{
ArgInteger(1);
if (argc > 1) {
ArgInteger(2);
RetStringN((void *)IntegerVal(argv[1]), IntegerVal(argv[2]));
}
else
RetInteger(*(word *)IntegerVal(argv[1]));
}
int spy(int argc, descriptor argv[]) /*: create spy-port to memory */
{
ArgInteger(1);
ArgInteger(2);
RetConstStringN((void *)IntegerVal(argv[1]), IntegerVal(argv[2]));
}
|