update
This commit is contained in:
parent
a03d8a440d
commit
e169ffc5ee
|
@ -12,15 +12,22 @@ struct gc_unit
|
||||||
gc_unit()
|
gc_unit()
|
||||||
{
|
{
|
||||||
collected=true;
|
collected=true;
|
||||||
//elem=0;
|
elem.set_clear();
|
||||||
refcnt=0;
|
refcnt=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gc_unit(const gc_unit& tmp)
|
gc_unit(const gc_unit& tmp)
|
||||||
{
|
{
|
||||||
collected=tmp.collected;
|
collected=tmp.collected;
|
||||||
//elem=tmp.elem;
|
elem =tmp.elem;
|
||||||
refcnt=tmp.refcnt;
|
refcnt =tmp.refcnt;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void set_clear()
|
||||||
|
{
|
||||||
|
collected=true;
|
||||||
|
elem.set_clear();
|
||||||
|
refcnt=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -61,7 +68,7 @@ class gc_manager
|
||||||
for(int i=0;i<memory_size;++i)
|
for(int i=0;i<memory_size;++i)
|
||||||
if((memory[i].refcnt<=0) && (!memory[i].collected))
|
if((memory[i].refcnt<=0) && (!memory[i].collected))
|
||||||
{
|
{
|
||||||
memory[i].collected=true;
|
memory[i].set_clear();
|
||||||
free_space.push_back(i);
|
free_space.push_back(i);
|
||||||
std::cout<<">> [Gc] collected ";
|
std::cout<<">> [Gc] collected ";
|
||||||
prt_hex(i);
|
prt_hex(i);
|
||||||
|
|
|
@ -5,6 +5,7 @@ class nasal_runtime
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
sym_hash_map global;
|
sym_hash_map global;
|
||||||
|
// local hash_map will be used when running
|
||||||
public:
|
public:
|
||||||
nasal_runtime()
|
nasal_runtime()
|
||||||
{
|
{
|
||||||
|
@ -18,14 +19,16 @@ class nasal_runtime
|
||||||
nasal_gc.gc_init();
|
nasal_gc.gc_init();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void before_running_init()
|
void func_proc()
|
||||||
{
|
{
|
||||||
global.set_clear();
|
|
||||||
nasal_gc.gc_init();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void main_proc(abstract_syntax_tree& root)
|
void main_proc(abstract_syntax_tree& root)
|
||||||
{
|
{
|
||||||
|
// init
|
||||||
|
global.set_clear();
|
||||||
|
nasal_gc.gc_init();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,22 @@ class nasal_function
|
||||||
function_root.set_clear();
|
function_root.set_clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void set_clear()
|
||||||
|
{
|
||||||
|
local_scope.clear();
|
||||||
|
function_root.set_clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nasal_function& operator=(const nasal_function& tmp)
|
||||||
|
{
|
||||||
|
local_scope=tmp.local_scope;
|
||||||
|
function_root=tmp.function_root;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
std::map<std::string,int>& get_local_scope()
|
||||||
|
{
|
||||||
|
return local_scope;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class nasal_scalar
|
class nasal_scalar
|
||||||
|
@ -45,8 +61,9 @@ class nasal_scalar
|
||||||
type=tmp.type;
|
type=tmp.type;
|
||||||
var_string=tmp.var_string;
|
var_string=tmp.var_string;
|
||||||
var_number=tmp.var_number;
|
var_number=tmp.var_number;
|
||||||
var_array=tmp.var_array;
|
var_array =tmp.var_array;
|
||||||
var_hash=tmp.var_hash;
|
var_hash =tmp.var_hash;
|
||||||
|
var_func =tmp.var_func;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nasal_scalar& operator=(const nasal_scalar& tmp)
|
nasal_scalar& operator=(const nasal_scalar& tmp)
|
||||||
|
@ -54,8 +71,9 @@ class nasal_scalar
|
||||||
type=tmp.type;
|
type=tmp.type;
|
||||||
var_string=tmp.var_string;
|
var_string=tmp.var_string;
|
||||||
var_number=tmp.var_number;
|
var_number=tmp.var_number;
|
||||||
var_array=tmp.var_array;
|
var_array =tmp.var_array;
|
||||||
var_hash=tmp.var_hash;
|
var_hash =tmp.var_hash;
|
||||||
|
var_func =tmp.var_func;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void set_clear()
|
void set_clear()
|
||||||
|
@ -65,6 +83,7 @@ class nasal_scalar
|
||||||
var_number=0;
|
var_number=0;
|
||||||
var_array.clear();
|
var_array.clear();
|
||||||
var_hash.clear();
|
var_hash.clear();
|
||||||
|
var_func.set_clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void set_type(const int tmp_type)
|
void set_type(const int tmp_type)
|
||||||
|
@ -97,7 +116,7 @@ class nasal_scalar
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int get_type() {return type;}
|
int get_type() {return type;}
|
||||||
double get_number() {return var_number;}
|
double get_number(){return var_number;}
|
||||||
std::string get_string(){return var_string;}
|
std::string get_string(){return var_string;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue