view ast/Decl.d @ 22:e331e4e816e4

now handling structs to some extend
author johnsen@johnsen-laptop
date Fri, 18 Apr 2008 23:45:45 +0200
parents 2168f4cb73f1
children 495188f9078e
line wrap: on
line source

module ast.Decl;

import ast.Exp,
       ast.Stmt;

import lexer.Token;

import sema.SymbolTable;

enum DeclType
{
    VarDecl,
    FuncDecl,
    StructDecl,
}

class Decl
{
    this(DeclType declType)
    {
        this.declType = declType;
    }

    DeclType declType;
    Scope env;
}

class VarDecl : Decl
{
    this(Identifier type, Identifier identifier,
            Exp e = null)
    {
        super(DeclType.VarDecl);
        this.type = type;
        this.identifier = identifier;
        this.init = e;
    }

    Identifier type, identifier;
    Exp init;
}

class FuncDecl : Decl
{
    this(Identifier type, Identifier identifier, 
            VarDecl[] funcArgs, Stmt[] statements)
    {
        super(DeclType.FuncDecl);
        this.type = type;
        this.identifier = identifier;
        this.funcArgs = funcArgs;
        this.statements = statements;
    }

    Identifier type, identifier;
    VarDecl[] funcArgs;
    Stmt[] statements;
}

class StructDecl : Decl
{
    this(Identifier identifier, 
            VarDecl[] vars)
    {
        super(DeclType.StructDecl);
        this.identifier = identifier;
        this.vars = vars;
    }

    Identifier identifier;
    VarDecl[] vars;
}