Recovered from cvs revision 2007-05-16 15:46:00

This commit is contained in:
hyung-hwan 2007-05-17 00:53:00 +00:00
parent a89fc5e2aa
commit b564cc2d8a
2 changed files with 68 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.28 2007/05/14 08:40:13 bacon Exp $
* $Id: Awk.cpp,v 1.29 2007/05/16 06:43:32 bacon Exp $
*/
#include <ase/awk/Awk.hpp>
@ -7,6 +7,9 @@
#include <ase/cmn/str.h>
#include <ase/cmn/mem.h>
#include <stdio.h>
#include <tchar.h>
namespace ASE
{
@ -155,7 +158,47 @@ namespace ASE
}
}
int Awk::Argument::init (run_t* run, ase_awk_val_t* v)
void* Awk::Argument::operator new (size_t n, awk_t* awk)
{
void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n);
if (ptr == ASE_NULL) return ASE_NULL;
*(awk_t**)ptr = awk;
return (char*)ptr+ASE_SIZEOF(awk);
}
void* Awk::Argument::operator new[] (size_t n, awk_t* awk)
{
void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n);
if (ptr == ASE_NULL) return ASE_NULL;
*(awk_t**)ptr = awk;
return (char*)ptr+ASE_SIZEOF(awk);
}
void Awk::Argument::operator delete (void* ptr, awk_t* awk)
{
ase_awk_free (awk, (char*)ptr-ASE_SIZEOF(awk));
}
void Awk::Argument::operator delete[] (void* ptr, awk_t* awk)
{
ase_awk_free (awk, (char*)ptr-ASE_SIZEOF(awk));
}
void Awk::Argument::operator delete (void* ptr)
{
void* p = (char*)ptr-ASE_SIZEOF(awk_t*);
ase_awk_free (*(awk_t**)p, p);
}
void Awk::Argument::operator delete[] (void* ptr)
{
void* p = (char*)ptr-ASE_SIZEOF(awk_t*);
ase_awk_free (*(awk_t**)p, p);
}
int Awk::Argument::init (run_t* run, val_t* v)
{
// this method is used internally only
// and should never be called more than once
@ -266,7 +309,7 @@ namespace ASE
clear ();
}
ase_awk_val_t* Awk::Return::toVal () const
Awk::val_t* Awk::Return::toVal () const
{
switch (this->type)
{
@ -537,8 +580,9 @@ namespace ASE
size_t i, nargs = ase_awk_getnargs(run);
Argument* args = ASE_NULL;
try { args = new Argument [nargs]; } catch (...) {}
//Argument* args = ASE_NULL;
//try { args = new Argument [nargs]; } catch (...) {}
Argument* args = new(awk) Argument[nargs];
if (args == ASE_NULL)
{
// TODO: SET ERROR INFO
@ -547,7 +591,7 @@ namespace ASE
for (i = 0; i < nargs; i++)
{
ase_awk_val_t* v = ase_awk_getarg (run, i);
val_t* v = ase_awk_getarg (run, i);
if (args[i].init (run, v) == -1)
{
delete[] args;
@ -568,7 +612,7 @@ namespace ASE
return -1;
}
ase_awk_val_t* r = ret.toVal ();
val_t* r = ret.toVal ();
if (r == ASE_NULL)
{
// TODO: SET ERROR INFO

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.26 2007/05/14 08:40:13 bacon Exp $
* $Id: Awk.hpp,v 1.27 2007/05/16 06:43:32 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_HPP_
@ -23,6 +23,7 @@ namespace ASE
typedef ase_long_t long_t;
typedef ase_real_t real_t;
typedef ase_awk_val_t val_t;
typedef ase_awk_map_t map_t;
typedef ase_awk_pair_t pair_t;
typedef ase_awk_extio_t extio_t;
@ -134,12 +135,24 @@ namespace ASE
Argument ();
~Argument ();
// initialization
void* operator new (size_t n, awk_t* awk);
void* operator new[] (size_t n, awk_t* awk);
// deletion when initialization fails
void operator delete (void* p, awk_t* awk);
void operator delete[] (void* p, awk_t* awk);
// normal deletion
void operator delete (void* p);
void operator delete[] (void* p);
private:
Argument (const Argument&);
Argument& operator= (const Argument&);
protected:
int init (run_t* run, ase_awk_val_t* v);
int init (run_t* run, val_t* v);
public:
long_t toInt () const;
@ -151,7 +164,7 @@ namespace ASE
protected:
run_t* run;
ase_awk_val_t* val;
val_t* val;
ase_long_t inum;
ase_real_t rnum;
@ -171,7 +184,7 @@ namespace ASE
Return (run_t* run);
~Return ();
ase_awk_val_t* toVal () const;
val_t* toVal () const;
public:
run_t* getRun () const;