# HG changeset patch # User Aziz K?ksal # Date 1199577996 -3600 # Node ID 87f09469d3371ef6765cf4f72f6dfe9a71a5f66e # Parent fc351756cc84d0e02067635fcf14d027b901b5a1 Moved class Parameter/s to module dil.ast.Parameter. diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/ast/Declarations.d --- a/trunk/src/dil/ast/Declarations.d Sun Jan 06 01:00:43 2008 +0100 +++ b/trunk/src/dil/ast/Declarations.d Sun Jan 06 01:06:36 2008 +0100 @@ -8,6 +8,7 @@ import dil.ast.Expressions; import dil.ast.Types; import dil.ast.Statements; +import dil.ast.Parameter; import dil.lexer.IdTable; import dil.semantic.Scope; import dil.semantic.Analysis; diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/ast/Expressions.d --- a/trunk/src/dil/ast/Expressions.d Sun Jan 06 01:00:43 2008 +0100 +++ b/trunk/src/dil/ast/Expressions.d Sun Jan 06 01:06:36 2008 +0100 @@ -8,6 +8,7 @@ import dil.ast.Types; import dil.ast.Declarations; import dil.ast.Statements; +import dil.ast.Parameter; import dil.lexer.Identifier; import dil.semantic.Scope; import dil.semantic.Types; diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/ast/Parameter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/dil/ast/Parameter.d Sun Jan 06 01:06:36 2008 +0100 @@ -0,0 +1,71 @@ +/++ + Author: Aziz Köksal + License: GPL3 ++/ +module dil.ast.Parameter; + +import dil.ast.Node; +import dil.ast.Types; +import dil.ast.Expressions; +import dil.lexer.Identifier; +import dil.Enums; + +class Parameter : Node +{ + StorageClass stc; + TypeNode type; + Identifier* ident; + Expression defValue; + + this(StorageClass stc, TypeNode type, Identifier* ident, Expression defValue) + { + super(NodeCategory.Other); + mixin(set_kind); + // type can be null when param in foreach statement + addOptChild(type); + addOptChild(defValue); + + this.stc = stc; + this.type = type; + this.ident = ident; + this.defValue = defValue; + } + + /// func(...) or func(int[] values ...) + bool isVariadic() + { + return !!(stc & StorageClass.Variadic); + } + + /// func(...) + bool isOnlyVariadic() + { + return stc == StorageClass.Variadic && + type is null && ident is null; + } +} + +class Parameters : Node +{ + this() + { + super(NodeCategory.Other); + mixin(set_kind); + } + + bool hasVariadic() + { + if (children.length != 0) + return items[$-1].isVariadic(); + return false; + } + + void opCatAssign(Parameter param) + { addChild(param); } + + Parameter[] items() + { return cast(Parameter[])children; } + + size_t length() + { return children.length; } +} diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/ast/Statements.d --- a/trunk/src/dil/ast/Statements.d Sun Jan 06 01:00:43 2008 +0100 +++ b/trunk/src/dil/ast/Statements.d Sun Jan 06 01:06:36 2008 +0100 @@ -8,6 +8,7 @@ import dil.ast.Expressions; import dil.ast.Declarations; import dil.ast.Types; +import dil.ast.Parameter; import dil.lexer.IdTable; import dil.semantic.Scope; import dil.semantic.Analysis; diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/ast/Types.d --- a/trunk/src/dil/ast/Types.d Sun Jan 06 01:00:43 2008 +0100 +++ b/trunk/src/dil/ast/Types.d Sun Jan 06 01:06:36 2008 +0100 @@ -6,71 +6,12 @@ import dil.ast.Node; import dil.ast.Expressions; +import dil.ast.Parameter; import dil.lexer.Identifier; import dil.Enums; import dil.semantic.Scope; import dil.semantic.Types; -class Parameter : Node -{ - StorageClass stc; - TypeNode type; - Identifier* ident; - Expression defValue; - - this(StorageClass stc, TypeNode type, Identifier* ident, Expression defValue) - { - super(NodeCategory.Other); - mixin(set_kind); - // type can be null when param in foreach statement - addOptChild(type); - addOptChild(defValue); - - this.stc = stc; - this.type = type; - this.ident = ident; - this.defValue = defValue; - } - - /// func(...) or func(int[] values ...) - bool isVariadic() - { - return !!(stc & StorageClass.Variadic); - } - - /// func(...) - bool isOnlyVariadic() - { - return stc == StorageClass.Variadic && - type is null && ident is null; - } -} - -class Parameters : Node -{ - this() - { - super(NodeCategory.Other); - mixin(set_kind); - } - - bool hasVariadic() - { - if (children.length != 0) - return items[$-1].isVariadic(); - return false; - } - - void opCatAssign(Parameter param) - { addChild(param); } - - Parameter[] items() - { return cast(Parameter[])children; } - - size_t length() - { return children.length; } -} - class BaseClass : Node { Protection prot; diff -r fc351756cc84 -r 87f09469d337 trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Sun Jan 06 01:00:43 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Sun Jan 06 01:06:36 2008 +0100 @@ -10,6 +10,7 @@ import dil.ast.Statements; import dil.ast.Expressions; import dil.ast.Types; +import dil.ast.Parameter; import dil.lexer.IdTable; import dil.Messages; import dil.Information;