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
d301ede4
Commit
d301ede4
authored
27 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
caches added
Rev: lib/master.pike:1.51
parent
295f3b8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/master.pike
+61
-6
61 additions, 6 deletions
lib/master.pike
with
61 additions
and
6 deletions
lib/master.pike
+
61
−
6
View file @
d301ede4
/* $Id: master.pike,v 1.5
0
1997/
09/16 00:30:15
hubbe Exp $
/* $Id: master.pike,v 1.5
1
1997/
10/02 04:33:27
hubbe Exp $
*
*
* Master-file for Pike.
* Master-file for Pike.
*/
*/
#define GETCWD_CACHE
#define FILE_STAT_CACHE
#define UNDEFINED (([])[0])
#define UNDEFINED (([])[0])
#define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) )
#define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) )
...
@@ -15,11 +18,54 @@ string *pike_include_path=({});
...
@@ -15,11 +18,54 @@ string *pike_include_path=({});
string *pike_module_path=({});
string *pike_module_path=({});
string *pike_program_path=({});
string *pike_program_path=({});
#ifdef GETCWD_CACHE
string current_path;
int cd(string s)
{
current_path=0;
return predef::cd(s);
}
string getcwd()
{
return current_path || (current_path=predef::getcwd());
}
#endif
string combine_path_with_cwd(string path)
string combine_path_with_cwd(string path)
{
{
return combine_path(path[0]=='/'?"/":getcwd(),path);
return combine_path(path[0]=='/'?"/":getcwd(),path);
}
}
#ifdef FILE_STAT_CACHE
mapping(string:multiset(string)) dir_cache = ([]);
mixed *file_stat(string x)
{
string file, dir=reverse(combine_path_with_cwd(x));
if(sscanf(dir,"%*[/]%s/%s", file, dir)!=3)
file=x;
file=reverse(file);
dir=reverse(dir);
multiset(string) d;
if(zero_type(d=dir_cache[dir]))
{
if(string *tmp=get_dir(dir))
{
d=dir_cache[dir]=aggregate_multiset(@tmp);
}else{
dir_cache[dir]=0;
}
}
if(d && !d[file]) return 0;
return predef::file_stat(x);
}
#endif
mapping (string:string) environment=([]);
mapping (string:string) environment=([]);
...
@@ -208,6 +254,11 @@ void create()
...
@@ -208,6 +254,11 @@ void create()
add_constant("clone",new);
add_constant("clone",new);
add_constant("UNDEFINED",UNDEFINED);
add_constant("UNDEFINED",UNDEFINED);
#ifdef GETCWD_CACHE
add_constant("cd",cd);
add_constant("getcwd",getcwd);
#endif
random_seed(time() + (getpid() * 0x11111111));
random_seed(time() + (getpid() * 0x11111111));
}
}
...
@@ -254,19 +305,23 @@ class dirnode
...
@@ -254,19 +305,23 @@ class dirnode
{
{
string dirname;
string dirname;
object tm;
object tm;
mixed module;
mapping cache=([]);
mapping cache=([]);
void create(string name, object the_master)
void create(string name, object the_master)
{
{
dirname=name;
dirname=name;
tm=the_master;
tm=the_master;
if(mixed module=tm->findmodule(dirname+"/module"))
if(mixed tmp=module->_module_value)
module=tmp;
}
}
object|program ind(string index)
object|program ind(string index)
{
{
if(mixed o=tm->findmodule(dirname+"/module"))
if(module) if(object o=module[index]) return o;
{
if(mixed tmp=o->_module_value) o=tmp;
if(o=o[index]) return o;
}
index = dirname+"/"+index;
index = dirname+"/"+index;
if(object o=tm->findmodule(index))
if(object o=tm->findmodule(index))
{
{
...
...
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