Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
2602b85a
Commit
2602b85a
authored
24 years ago
by
Martin Stjernholm
Browse files
Options
Downloads
Patches
Plain Diff
Broke apart the describer functions a bit to make it easier to
overload. Rev: lib/master.pike.in:1.128
parent
6fd0f6e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/master.pike.in
+86
-64
86 additions, 64 deletions
lib/master.pike.in
with
86 additions
and
64 deletions
lib/master.pike.in
+
86
−
64
View file @
2602b85a
/* -*- Pike -*-
*
* $Id: master.pike.in,v 1.12
7
2000/08/29
14:46:36
mast Exp $
* $Id: master.pike.in,v 1.12
8
2000/08/29
21:54:01
mast Exp $
*
* Master-file for Pike.
*
...
...
@@ -1420,10 +1420,58 @@ class Describer
foreach (indices (stuff), mixed elem)
identify_parts (elem), identify_parts (stuff[elem]);
}
else if (objectp (stuff))
else if (objectp
(stuff) || functionp (stuff) || programp
(stuff))
ident[stuff]++;
}
string describe_string (string m, int maxlen)
{
canclip++;
if(sizeof(m) < maxlen)
{
string t = sprintf("%O", m);
if (sizeof(t) < (maxlen + 2)) {
return t;
}
t = 0;
}
clipped++;
if(maxlen>10)
{
return sprintf("%O+[%d]",m[..maxlen-5],sizeof(m)-(maxlen-5));
}else{
return "string["+sizeof(m)+"]";
}
}
string describe_array (array m, int maxlen)
{
if(!sizeof(m)) return "({})";
else {
if(maxlen<5)
{
clipped++;
return "array["+sizeof(m)+"]";
}
else {
canclip++;
return "({" + describe_comma_list(m,maxlen-2) +"})";
}
}
}
string describe_mapping (mapping m, int maxlen)
{
if(!sizeof(m)) return "([])";
else return "mapping["+sizeof(m)+"]";
}
string describe_multiset (multiset m, int maxlen)
{
if(!sizeof(m)) return "(<>)";
else return "multiset["+sizeof(m)+"]";
}
string describe (mixed m, int maxlen)
{
if (stringp (ident[m])) return ident[m];
...
...
@@ -1438,76 +1486,32 @@ class Describer
case "int":
case "float":
return (string)m;
case "string":
canclip++;
if(sizeof(m) < maxlen)
{
string t = sprintf("%O", m);
if (sizeof(t) < (maxlen + 2)) {
return t;
}
t = 0;
}
clipped++;
if(maxlen>10)
{
return sprintf("%O+[%d]",m[..maxlen-5],sizeof(m)-(maxlen-5));
}else{
return "string["+sizeof(m)+"]";
}
return describe_string (m, maxlen);
case "array":
if(!sizeof(m)) res = "({})";
else {
if(maxlen<5)
{
clipped++;
res = "array["+sizeof(m)+"]";
}
else {
canclip++;
res = "({" + describe_comma_list(m,maxlen-2) +"})";
}
}
res = describe_array (m, maxlen);
break;
case "mapping":
if(!sizeof(m)) res = "([])";
else res = "mapping["+sizeof(m)+"]";
res = describe_mapping (m, maxlen);
break;
case "multiset":
if(!sizeof(m)) res = "(<>)";
else res = "multiset["+sizeof(m)+"]";
res = describe_multiset (m, maxlen);
break;
case "function":
if(string tmp=describe_program(m)) return tmp;
if(object o=function_object(m)) {
string s = describe_object(o);
if (s && s != "object") return s+"->"+function_name(m);
else return function_name(m);
}
else {
string tmp;
if (catch (tmp = function_name(m)))
// The function object has probably been destructed.
return "function";
return tmp || "function";
}
if (string tmp=describe_function(m)) res = tmp;
else res = typ;
break;
case "program":
if(string tmp=describe_program(m)) re
turn
tmp;
return
typ;
if(string tmp=describe_program(m)) re
s =
tmp;
else res =
typ;
break;
default:
if (objectp(m))
if(string tmp=describe_object(m)) {
res = tmp;
break;
}
re
turn
typ;
re
s =
typ;
}
if (stringp (ident[m]))
...
...
@@ -1644,6 +1648,30 @@ string describe_program(program p)
return 0;
}
string describe_function (function f)
{
if (!f) return 0;
string name;
if(string s=search(programs,f))
{
if(sscanf(reverse(s),"%s.%s",string ext,string rest) && ext=="domp")
name = EXPLODE_PATH(reverse(rest))[-1];
else
name = trim_file_name(s);
}
else
if (catch (name = function_name (f))) name = "function";
if(object o=function_object(f)) {
string s;
if (!catch (s = sprintf("%O",o)) && s != "object")
return s+"->"+name;
}
return name;
}
/* It is possible that this should be a real efun,
* it is currently used by handle_error to convert a backtrace to a
* readable message.
...
...
@@ -1728,13 +1756,7 @@ string describe_backtrace(mixed trace, void|int linewidth)
if(sizeof(tmp)>=3)
{
if(functionp(tmp[2])) {
data = "";
if (object o = function_object(tmp[2])) {
string s;
if (!catch (s = sprintf("%O",o)) && s != "object")
data = s + "->";
}
data += function_name(tmp[2]);
data = describe_function (tmp[2]);
}
else if (stringp(tmp[2])) {
data= tmp[2];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment