fix typos
This commit is contained in:
parent
9e2e7f5809
commit
ca1ae75b07
18 changed files with 62 additions and 55 deletions
|
|
@ -114,46 +114,46 @@ Object* objects_api::instantiate(Object* in) {
|
|||
}
|
||||
|
||||
void objects_api::set(Object* self, alni val) {
|
||||
if (self->type->convesions && self->type->convesions->from_int) {
|
||||
self->type->convesions->from_int(self, val);
|
||||
if (self->type->conversions && self->type->conversions->from_int) {
|
||||
self->type->conversions->from_int(self, val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void objects_api::set(Object* self, alnf val) {
|
||||
if (self->type->convesions && self->type->convesions->from_float) {
|
||||
self->type->convesions->from_float(self, val);
|
||||
if (self->type->conversions && self->type->conversions->from_float) {
|
||||
self->type->conversions->from_float(self, val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void objects_api::set(Object* self, const std::string& val) {
|
||||
if (self->type->convesions && self->type->convesions->from_string) {
|
||||
self->type->convesions->from_string(self, val);
|
||||
if (self->type->conversions && self->type->conversions->from_string) {
|
||||
self->type->conversions->from_string(self, val);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
alni objects_api::toInt(Object* self) {
|
||||
DEBUG_ASSERT(self->type->convesions && self->type->convesions->to_int)
|
||||
return self->type->convesions->to_int(self);
|
||||
DEBUG_ASSERT(self->type->conversions && self->type->conversions->to_int)
|
||||
return self->type->conversions->to_int(self);
|
||||
}
|
||||
|
||||
alnf objects_api::toFloat(Object* self) {
|
||||
DEBUG_ASSERT(self->type->convesions && self->type->convesions->to_float)
|
||||
return self->type->convesions->to_float(self);
|
||||
DEBUG_ASSERT(self->type->conversions && self->type->conversions->to_float)
|
||||
return self->type->conversions->to_float(self);
|
||||
}
|
||||
|
||||
bool objects_api::toBool(Object* self) {
|
||||
if (self->type->convesions && self->type->convesions->to_int) {
|
||||
return (bool) self->type->convesions->to_int(self);
|
||||
if (self->type->conversions && self->type->conversions->to_int) {
|
||||
return (bool) self->type->conversions->to_int(self);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string objects_api::toString(Object* self) {
|
||||
DEBUG_ASSERT(self->type->convesions && self->type->convesions->to_string)
|
||||
return self->type->convesions->to_string(self);
|
||||
DEBUG_ASSERT(self->type->conversions && self->type->conversions->to_string)
|
||||
return self->type->conversions->to_string(self);
|
||||
}
|
||||
|
||||
void objects_api::destroy(Object* in) const {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ TypeMethod obj::gDefaultTypeMethods[] = {
|
|||
.descr = "converts to string",
|
||||
.exec =
|
||||
[](const TypeMethod* tm) {
|
||||
if (tm->self->type->convesions && tm->self->type->convesions->to_string) {
|
||||
if (tm->self->type->conversions && tm->self->type->conversions->to_string) {
|
||||
tm->ret.obj = StringObject::create(NDO->toString(tm->self));
|
||||
}
|
||||
},
|
||||
|
|
@ -33,7 +33,7 @@ TypeMethod obj::gDefaultTypeMethods[] = {
|
|||
.descr = "converts to float",
|
||||
.exec =
|
||||
[](const TypeMethod* tm) {
|
||||
if (tm->self->type->convesions && tm->self->type->convesions->to_float) {
|
||||
if (tm->self->type->conversions && tm->self->type->conversions->to_float) {
|
||||
tm->ret.obj = FloatObject::create(NDO->toFloat(tm->self));
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::PRINT:
|
||||
{
|
||||
auto obj = mOperandsStack.getOperand();
|
||||
if (obj->type->convesions && obj->type->convesions->to_string) {
|
||||
if (obj->type->conversions && obj->type->conversions->to_string) {
|
||||
auto str = NDO->toString(obj);
|
||||
printf("%s\n", str.c_str());
|
||||
} else {
|
||||
|
|
@ -390,10 +390,10 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto right = mOperandsStack.getOperand();
|
||||
|
||||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->ariphmetics && left->type->ariphmetics->add && "cannot add object of this type");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
res->type->ariphmetics->add(res, right);
|
||||
res->type->arithmetics->add(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
mOperandsStack.push(res);
|
||||
|
|
@ -405,10 +405,10 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto right = mOperandsStack.getOperand();
|
||||
|
||||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->ariphmetics && left->type->ariphmetics->add && "cannot add object of this type");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
res->type->ariphmetics->sub(res, right);
|
||||
res->type->arithmetics->sub(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
mOperandsStack.push(res);
|
||||
|
|
@ -420,10 +420,10 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto right = mOperandsStack.getOperand();
|
||||
|
||||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->ariphmetics && left->type->ariphmetics->add && "cannot add object of this type");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
res->type->ariphmetics->mul(res, right);
|
||||
res->type->arithmetics->mul(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
mOperandsStack.push(res);
|
||||
|
|
@ -435,10 +435,10 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto right = mOperandsStack.getOperand();
|
||||
|
||||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->ariphmetics && left->type->ariphmetics->add && "cannot add object of this type");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
res->type->ariphmetics->div(res, right);
|
||||
res->type->arithmetics->div(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
mOperandsStack.push(res);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct obj::ObjectType obj::BoolObject::TypeData = {
|
|||
.copy = (object_copy) BoolObject::copy,
|
||||
.size = sizeof(BoolObject),
|
||||
.name = "bool",
|
||||
.convesions = &BoolObjectTypeConversions,
|
||||
.conversions = &BoolObjectTypeConversions,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void sub(ColorObject* self, ColorObject* in) { self->mCol = in->mCol - self->mCo
|
|||
|
||||
void add(ColorObject* self, ColorObject* in) { self->mCol = in->mCol + self->mCol; }
|
||||
|
||||
struct ObjectTypeAriphmetics ColorObject::TypeAriphm = {
|
||||
struct ObjectTypeArithmetics ColorObject::TypeAriphm = {
|
||||
.add = (object_add) add,
|
||||
.sub = (object_sub) sub,
|
||||
.mul = (object_mul) nullptr,
|
||||
|
|
@ -61,8 +61,8 @@ struct obj::ObjectType obj::ColorObject::TypeData = {
|
|||
.copy = (object_copy) ColorObject::copy,
|
||||
.size = sizeof(ColorObject),
|
||||
.name = "RGBA",
|
||||
.convesions = &ColorObjectTypeConversions,
|
||||
.ariphmetics = &ColorObject::TypeAriphm,
|
||||
.conversions = &ColorObjectTypeConversions,
|
||||
.arithmetics = &ColorObject::TypeAriphm,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -134,7 +134,9 @@ static void load(ArchiverIn& file_self, EnumObject* self) {
|
|||
file_self.readBytes((tp::int1*) self->entries, self->nentries * ENV_ALNI_SIZE_B);
|
||||
}
|
||||
|
||||
bool obj::EnumObject::compare(EnumObject* first, EnumObject* second) { return first->entries != nullptr && second->entries != nullptr && first->active == second->active; }
|
||||
bool obj::EnumObject::compare(EnumObject* first, EnumObject* second) {
|
||||
return first->entries != nullptr && second->entries != nullptr && first->active == second->active;
|
||||
}
|
||||
|
||||
EnumObject* obj::EnumObject::create(tp::InitialierList<const char*> list) {
|
||||
auto enum_object = (EnumObject*) obj::NDO->create("enum");
|
||||
|
|
@ -166,7 +168,7 @@ struct obj::ObjectType obj::EnumObject::TypeData = {
|
|||
.copy = (object_copy) EnumObject::copy,
|
||||
.size = sizeof(EnumObject),
|
||||
.name = "enum",
|
||||
.convesions = &EnumObjectTypeConversions,
|
||||
.conversions = &EnumObjectTypeConversions,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void add(FloatObject* self, FloatObject* in) { self->val += in->val; }
|
|||
|
||||
static void divide(FloatObject* self, FloatObject* in) { self->val /= in->val; }
|
||||
|
||||
struct ObjectTypeAriphmetics FloatObject::TypeAriphm = {
|
||||
struct ObjectTypeArithmetics FloatObject::TypeAriphm = {
|
||||
.add = (object_add) add,
|
||||
.sub = (object_sub) sub,
|
||||
.mul = (object_mul) mul,
|
||||
|
|
@ -62,8 +62,8 @@ struct obj::ObjectType obj::FloatObject::TypeData = {
|
|||
.copy = (object_copy) FloatObject::copy,
|
||||
.size = sizeof(FloatObject),
|
||||
.name = "float",
|
||||
.convesions = &FloatObjectTypeConversions,
|
||||
.ariphmetics = &FloatObject::TypeAriphm,
|
||||
.conversions = &FloatObjectTypeConversions,
|
||||
.arithmetics = &FloatObject::TypeAriphm,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void sub(IntObject* self, IntObject* in) { self->val -= in->val; }
|
|||
|
||||
void add(IntObject* self, IntObject* in) { self->val += in->val; }
|
||||
|
||||
struct ObjectTypeAriphmetics IntObject::TypeAriphm = {
|
||||
struct ObjectTypeArithmetics IntObject::TypeAriphm = {
|
||||
.add = (object_add) add,
|
||||
.sub = (object_sub) sub,
|
||||
.mul = (object_mul) mul,
|
||||
|
|
@ -63,8 +63,8 @@ struct obj::ObjectType obj::IntObject::TypeData = {
|
|||
.copy = (object_copy) IntObject::copy,
|
||||
.size = sizeof(IntObject),
|
||||
.name = "int",
|
||||
.convesions = &IntObjectTypeConversions,
|
||||
.ariphmetics = &IntObject::TypeAriphm,
|
||||
.conversions = &IntObjectTypeConversions,
|
||||
.arithmetics = &IntObject::TypeAriphm,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ struct obj::ObjectType LinkObject::TypeData = {
|
|||
.size = sizeof(LinkObject),
|
||||
.name = "link",
|
||||
|
||||
.convesions = nullptr,
|
||||
.conversions = nullptr,
|
||||
|
||||
.save_size = (object_save_size) LinkObject::save_size,
|
||||
.save = (object_save) LinkObject::save,
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ struct obj::ObjectType obj::ListObject::TypeData = {
|
|||
.copy = (object_copy) ListObject::copy,
|
||||
.size = sizeof(ListObject),
|
||||
.name = "list",
|
||||
.convesions = nullptr,
|
||||
|
||||
.conversions = nullptr,
|
||||
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -13,15 +13,19 @@ struct ObjectType MethodObject::TypeData = {
|
|||
.copy = (object_copy) MethodObject::copy,
|
||||
.size = sizeof(MethodObject),
|
||||
.name = "method",
|
||||
.convesions = nullptr,
|
||||
.conversions = nullptr,
|
||||
.save_size = (object_save_size) MethodObject::save_size,
|
||||
.save = (object_save) MethodObject::save,
|
||||
.load = (object_load) MethodObject::load,
|
||||
};
|
||||
|
||||
void MethodObject::constructor(MethodObject* self) { self->mScript = obj::ScriptSection::globalHandle()->createScript(); }
|
||||
void MethodObject::constructor(MethodObject* self) {
|
||||
self->mScript = obj::ScriptSection::globalHandle()->createScript();
|
||||
}
|
||||
|
||||
void MethodObject::copy(MethodObject* self, MethodObject* in) { obj::ScriptSection::globalHandle()->changeScript(&self->mScript, &in->mScript); }
|
||||
void MethodObject::copy(MethodObject* self, MethodObject* in) {
|
||||
obj::ScriptSection::globalHandle()->changeScript(&self->mScript, &in->mScript);
|
||||
}
|
||||
|
||||
void MethodObject::destructor(MethodObject* self) { obj::ScriptSection::globalHandle()->abandonScript(self->mScript); }
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ void NullObject::uninit() {
|
|||
NdoNull_globalInstance = nullptr;
|
||||
}
|
||||
|
||||
void NullObject::destructor(Object* self) { DEBUG_ASSERT(uninit_flag && "Only one the instance of NullObject exists and thus it can't be destroyed"); }
|
||||
void NullObject::destructor(Object* self) {
|
||||
DEBUG_ASSERT(uninit_flag && "Only one the instance of NullObject exists and thus it can't be destroyed");
|
||||
}
|
||||
|
||||
std::string to_string(NullObject* self) { return "nullptr"; }
|
||||
|
||||
|
|
@ -44,5 +46,5 @@ struct ObjectType NullObject::TypeData = {
|
|||
.copy = nullptr,
|
||||
.size = sizeof(NullObject),
|
||||
.name = "null",
|
||||
.convesions = &NullObjectTypeConversions,
|
||||
.conversions = &NullObjectTypeConversions,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ struct obj::ObjectType StringObject::TypeData = {
|
|||
.copy = (object_copy) StringObject::copy,
|
||||
.size = sizeof(StringObject),
|
||||
.name = "str",
|
||||
.convesions = &StringObjectTypeConversions,
|
||||
.conversions = &StringObjectTypeConversions,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ struct obj::ObjectType TypeObject::TypeData = {
|
|||
//.constructor = (object_constructor) TypeObject::constructor,
|
||||
.size = sizeof(TypeObject),
|
||||
.name = "typeobject",
|
||||
.convesions = &conversions,
|
||||
.conversions = &conversions,
|
||||
.save_size = (object_save_size) save_size,
|
||||
.save = (object_save) save,
|
||||
.load = (object_load) load,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue