compiler: Formatting

This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2019-01-18 17:04:57 +01:00
parent 79cc5fae95
commit c9ff5b8ca4
34 changed files with 7101 additions and 3392 deletions
+52 -39
View File
@@ -1,61 +1,74 @@
#include "std.hpp"
#include "type.hpp"
#include "std.hpp"
static struct v_type : public Type{
bool canCastTo( Type *t ){
return t==Type::void_type;
static struct v_type : public Type {
bool canCastTo(Type* t)
{
return t == Type::void_type;
}
}v;
} v;
static struct i_type : public Type{
bool intType(){
return true;
}
bool canCastTo( Type *t ){
return t==Type::int_type || t==Type::float_type || t==Type::string_type;
}
}i;
static struct f_type : public Type{
bool floatType(){
static struct i_type : public Type {
bool intType()
{
return true;
}
bool canCastTo( Type *t ){
return t==Type::int_type || t==Type::float_type || t==Type::string_type;
bool canCastTo(Type* t)
{
return t == Type::int_type || t == Type::float_type || t == Type::string_type;
}
}f;
} i;
static struct s_type : public Type{
bool stringType(){
static struct f_type : public Type {
bool floatType()
{
return true;
}
bool canCastTo( Type *t ){
return t==Type::int_type || t==Type::float_type || t==Type::string_type;
bool canCastTo(Type* t)
{
return t == Type::int_type || t == Type::float_type || t == Type::string_type;
}
}s;
} f;
bool StructType::canCastTo( Type *t ){
return t==this || t==Type::null_type || (this==Type::null_type && t->structType());
static struct s_type : public Type {
bool stringType()
{
return true;
}
bool canCastTo(Type* t)
{
return t == Type::int_type || t == Type::float_type || t == Type::string_type;
}
} s;
bool StructType::canCastTo(Type* t)
{
return t == this || t == Type::null_type || (this == Type::null_type && t->structType());
}
bool VectorType::canCastTo( Type *t ){
if( this==t ) return true;
if( VectorType *v=t->vectorType() ){
if( elementType!=v->elementType ) return false;
if( sizes.size()!=v->sizes.size() ) return false;
for( int k=0;k<sizes.size();++k ){
if( sizes[k]!=v->sizes[k] ) return false;
bool VectorType::canCastTo(Type* t)
{
if (this == t)
return true;
if (VectorType* v = t->vectorType()) {
if (elementType != v->elementType)
return false;
if (sizes.size() != v->sizes.size())
return false;
for (int k = 0; k < sizes.size(); ++k) {
if (sizes[k] != v->sizes[k])
return false;
}
return true;
}
return false;
}
static StructType n( "Null" );
static StructType n("Null");
Type *Type::void_type=&v;
Type *Type::int_type=&i;
Type *Type::float_type=&f;
Type *Type::string_type=&s;
Type *Type::null_type=&n;
Type* Type::void_type = &v;
Type* Type::int_type = &i;
Type* Type::float_type = &f;
Type* Type::string_type = &s;
Type* Type::null_type = &n;