view trunk/src/Types.d @ 95:0eb4c8a5b32b

- Added TOK.Invalid. - Moved STC as StorageClass to module Type. - Added In, Out, Ref, Lazy and Variadic to StorageClass. - Added member 'next' to class Type to represent non-basic types like pointers, arrays etc. - Added class PointerType and ArrayType. - Added class Argument to represent function parameters. - Implemented most of parseBasicType2() and parseParameters().
author aziz
date Fri, 06 Jul 2007 18:37:03 +0000
parents 0fe650a7a8d1
children 538e8b546669
line wrap: on
line source

/++
  Author: Aziz Köksal
  License: GPL2
+/
module Types;
import Token;
import Expressions;

enum StorageClass
{
  None         = 0,
  Abstract     = 1,
  Auto         = 1<<2,
  Const        = 1<<3,
  Deprecated   = 1<<4,
  Extern       = 1<<5,
  Final        = 1<<6,
  Invariant    = 1<<7,
  Override     = 1<<8,
  Scope        = 1<<9,
  Static       = 1<<10,
  Synchronized = 1<<11,
  In           = 1<<12,
  Out          = 1<<13,
  Ref          = 1<<14,
  Lazy         = 1<<15,
  Variadic     = 1<<16,
}

class Type
{
  TOK type;
  Type next;

  this(TOK type)
  { this(type, null); }

  this(TOK type, Type next)
  {
    this.type = type;
    this.next = next;
  }
}

class IdentifierType : Type
{
  string[] idents;

  this(string[] idents)
  {
    super(TOK.Identifier, null);
    this.idents = idents;
  }

  this(TOK type)
  {
    super(type, null);
  }

  void opCatAssign(string ident)
  {
    this.idents ~= ident;
  }
}

class TypeofType : IdentifierType
{
  Expression e;
  this(Expression e)
  {
    super(TOK.Typeof);
    this.e = e;
  }
}

class PointerType : Type
{
  this(Type t)
  {
    super(TOK.Mul, t);
  }
}

class ArrayType : Type
{
  Expression e;
  this(Type t, Expression e)
  {
    super(TOK.Invalid, t);
    this.e = e;
  }
}