Mercurial > projects > dil
changeset 608:fac9e8b258fc
Moved dil.ast.Parameter to dil.ast.Parameters.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 06 Jan 2008 15:26:03 +0100 |
parents | 2ed1e6d638cd |
children | 0c10255d8009 |
files | trunk/src/dil/ast/Declarations.d trunk/src/dil/ast/Expressions.d trunk/src/dil/ast/Parameter.d trunk/src/dil/ast/Parameters.d trunk/src/dil/ast/Statements.d trunk/src/dil/ast/Types.d trunk/src/dil/parser/Parser.d |
diffstat | 7 files changed, 199 insertions(+), 199 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/dil/ast/Declarations.d Sun Jan 06 15:23:40 2008 +0100 +++ b/trunk/src/dil/ast/Declarations.d Sun Jan 06 15:26:03 2008 +0100 @@ -8,7 +8,7 @@ import dil.ast.Expressions; import dil.ast.Types; import dil.ast.Statements; -import dil.ast.Parameter; +import dil.ast.Parameters; import dil.ast.BaseClass; import dil.lexer.IdTable; import dil.semantic.Scope;
--- a/trunk/src/dil/ast/Expressions.d Sun Jan 06 15:23:40 2008 +0100 +++ b/trunk/src/dil/ast/Expressions.d Sun Jan 06 15:26:03 2008 +0100 @@ -8,7 +8,7 @@ import dil.ast.Types; import dil.ast.Declarations; import dil.ast.Statements; -import dil.ast.Parameter; +import dil.ast.Parameters; import dil.ast.BaseClass; import dil.lexer.Identifier; import dil.semantic.Scope;
--- a/trunk/src/dil/ast/Parameter.d Sun Jan 06 15:23:40 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -/++ - 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; } -} - -/********************* - Template parameters: -*/ - -abstract class TemplateParameter : Node -{ - Identifier* ident; - this(Identifier* ident) - { - super(NodeCategory.Other); - this.ident = ident; - } -} - -class TemplateAliasParameter : TemplateParameter -{ - TypeNode specType, defType; - this(Identifier* ident, TypeNode specType, TypeNode defType) - { - super(ident); - mixin(set_kind); - addOptChild(specType); - addOptChild(defType); - this.ident = ident; - this.specType = specType; - this.defType = defType; - } -} - -class TemplateTypeParameter : TemplateParameter -{ - TypeNode specType, defType; - this(Identifier* ident, TypeNode specType, TypeNode defType) - { - super(ident); - mixin(set_kind); - addOptChild(specType); - addOptChild(defType); - this.ident = ident; - this.specType = specType; - this.defType = defType; - } -} - -version(D2) -{ -class TemplateThisParameter : TemplateParameter -{ - TypeNode specType, defType; - this(Identifier* ident, TypeNode specType, TypeNode defType) - { - super(ident); - mixin(set_kind); - addOptChild(specType); - addOptChild(defType); - this.ident = ident; - this.specType = specType; - this.defType = defType; - } -} -} - -class TemplateValueParameter : TemplateParameter -{ - TypeNode valueType; - Expression specValue, defValue; - this(TypeNode valueType, Identifier* ident, Expression specValue, Expression defValue) - { - super(ident); - mixin(set_kind); - addChild(valueType); - addOptChild(specValue); - addOptChild(defValue); - this.valueType = valueType; - this.ident = ident; - this.specValue = specValue; - this.defValue = defValue; - } -} - -class TemplateTupleParameter : TemplateParameter -{ - this(Identifier* ident) - { - super(ident); - mixin(set_kind); - this.ident = ident; - } -} - -class TemplateParameters : Node -{ - this() - { - super(NodeCategory.Other); - mixin(set_kind); - } - - void opCatAssign(TemplateParameter parameter) - { - addChild(parameter); - } - - TemplateParameter[] items() - { - return cast(TemplateParameter[])children; - } -} - -class TemplateArguments : Node -{ - this() - { - super(NodeCategory.Other); - mixin(set_kind); - } - - void opCatAssign(Node argument) - { - addChild(argument); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/dil/ast/Parameters.d Sun Jan 06 15:26:03 2008 +0100 @@ -0,0 +1,194 @@ +/++ + Author: Aziz Köksal + License: GPL3 ++/ +module dil.ast.Parameters; + +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; } +} + +/********************* + Template parameters: +*/ + +abstract class TemplateParameter : Node +{ + Identifier* ident; + this(Identifier* ident) + { + super(NodeCategory.Other); + this.ident = ident; + } +} + +class TemplateAliasParameter : TemplateParameter +{ + TypeNode specType, defType; + this(Identifier* ident, TypeNode specType, TypeNode defType) + { + super(ident); + mixin(set_kind); + addOptChild(specType); + addOptChild(defType); + this.ident = ident; + this.specType = specType; + this.defType = defType; + } +} + +class TemplateTypeParameter : TemplateParameter +{ + TypeNode specType, defType; + this(Identifier* ident, TypeNode specType, TypeNode defType) + { + super(ident); + mixin(set_kind); + addOptChild(specType); + addOptChild(defType); + this.ident = ident; + this.specType = specType; + this.defType = defType; + } +} + +version(D2) +{ +class TemplateThisParameter : TemplateParameter +{ + TypeNode specType, defType; + this(Identifier* ident, TypeNode specType, TypeNode defType) + { + super(ident); + mixin(set_kind); + addOptChild(specType); + addOptChild(defType); + this.ident = ident; + this.specType = specType; + this.defType = defType; + } +} +} + +class TemplateValueParameter : TemplateParameter +{ + TypeNode valueType; + Expression specValue, defValue; + this(TypeNode valueType, Identifier* ident, Expression specValue, Expression defValue) + { + super(ident); + mixin(set_kind); + addChild(valueType); + addOptChild(specValue); + addOptChild(defValue); + this.valueType = valueType; + this.ident = ident; + this.specValue = specValue; + this.defValue = defValue; + } +} + +class TemplateTupleParameter : TemplateParameter +{ + this(Identifier* ident) + { + super(ident); + mixin(set_kind); + this.ident = ident; + } +} + +class TemplateParameters : Node +{ + this() + { + super(NodeCategory.Other); + mixin(set_kind); + } + + void opCatAssign(TemplateParameter parameter) + { + addChild(parameter); + } + + TemplateParameter[] items() + { + return cast(TemplateParameter[])children; + } +} + +class TemplateArguments : Node +{ + this() + { + super(NodeCategory.Other); + mixin(set_kind); + } + + void opCatAssign(Node argument) + { + addChild(argument); + } +}
--- a/trunk/src/dil/ast/Statements.d Sun Jan 06 15:23:40 2008 +0100 +++ b/trunk/src/dil/ast/Statements.d Sun Jan 06 15:26:03 2008 +0100 @@ -8,7 +8,7 @@ import dil.ast.Expressions; import dil.ast.Declarations; import dil.ast.Types; -import dil.ast.Parameter; +import dil.ast.Parameters; import dil.lexer.IdTable; import dil.semantic.Scope; import dil.semantic.Analysis;
--- a/trunk/src/dil/ast/Types.d Sun Jan 06 15:23:40 2008 +0100 +++ b/trunk/src/dil/ast/Types.d Sun Jan 06 15:26:03 2008 +0100 @@ -6,7 +6,7 @@ import dil.ast.Node; import dil.ast.Expressions; -import dil.ast.Parameter; +import dil.ast.Parameters; import dil.lexer.Identifier; import dil.Enums; import dil.semantic.Scope;
--- a/trunk/src/dil/parser/Parser.d Sun Jan 06 15:23:40 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Sun Jan 06 15:26:03 2008 +0100 @@ -10,7 +10,7 @@ import dil.ast.Statements; import dil.ast.Expressions; import dil.ast.Types; -import dil.ast.Parameter; +import dil.ast.Parameters; import dil.ast.BaseClass; import dil.lexer.IdTable; import dil.Messages;