Commit 610168a4 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Support `new' as member modifier in parser to prepare support for hiding

2009-02-12  Jürg Billeter  <j@bitron.ch>

	* vala/valamember.vala:
	* vala/valaparser.vala:

	Support `new' as member modifier in parser to prepare support for
	hiding members, patch by Andreas Brauchli

svn path=/trunk/; revision=2435
parent c358b874
2009-02-12 Jürg Billeter <j@bitron.ch>
* vala/valamember.vala:
* vala/valaparser.vala:
Support `new' as member modifier in parser to prepare support for
hiding members, patch by Andreas Brauchli
2009-02-12 Ryan Lortie <desrt@desrt.ca>
* vala/valamethod.vala:
......
......@@ -69,6 +69,7 @@ Rob Taylor
Roberto Majadas
Roland Hostettler
Ross Burton
Ryan Lortie
Sam Liddicott
Samuel Cormier-Iijima
Sebastian Dröge
......
......@@ -29,6 +29,12 @@ using Gee;
public abstract class Vala.Member : Symbol {
private Gee.List<string> cheader_filenames = new ArrayList<string> ();
/**
* Specifies whether this method explicitly hides a member of a base
* type.
*/
public bool hides { get; set; }
public Member (string? name, SourceReference? source_reference) {
base (name, source_reference);
}
......
......@@ -54,9 +54,10 @@ public class Vala.Parser : CodeVisitor {
CLASS = 1 << 1,
EXTERN = 1 << 2,
INLINE = 1 << 3,
OVERRIDE = 1 << 4,
STATIC = 1 << 5,
VIRTUAL = 1 << 6
NEW = 1 << 4,
OVERRIDE = 1 << 5,
STATIC = 1 << 6,
VIRTUAL = 1 << 7
}
public Parser () {
......@@ -1858,6 +1859,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.INTERFACE:
case TokenType.INTERNAL:
case TokenType.NAMESPACE:
case TokenType.NEW:
case TokenType.OVERRIDE:
case TokenType.PRIVATE:
case TokenType.PROTECTED:
......@@ -2085,6 +2087,9 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
c.external = true;
}
if (ModifierFlags.NEW in flags) {
c.hides = true;
}
set_attributes (c, attrs);
return c;
}
......@@ -2111,6 +2116,9 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
f.external = true;
}
if (ModifierFlags.NEW in flags) {
f.hides = true;
}
if (accept (TokenType.ASSIGN)) {
f.initializer = parse_expression ();
}
......@@ -2147,6 +2155,9 @@ public class Vala.Parser : CodeVisitor {
} else if (ModifierFlags.CLASS in flags) {
method.binding = MemberBinding.CLASS;
}
if (ModifierFlags.NEW in flags) {
method.hides = true;
}
if (method.binding == MemberBinding.INSTANCE) {
if (ModifierFlags.ABSTRACT in flags) {
......@@ -2243,6 +2254,9 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.OVERRIDE in flags) {
prop.overrides = true;
}
if (ModifierFlags.NEW in flags) {
prop.hides = true;
}
if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
prop.external = true;
}
......@@ -2344,6 +2358,9 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.VIRTUAL in flags) {
sig.is_virtual = true;
}
if (ModifierFlags.NEW in flags) {
sig.hides = true;
}
expect (TokenType.OPEN_PARENS);
if (current () != TokenType.CLOSE_PARENS) {
do {
......@@ -2360,6 +2377,9 @@ public class Vala.Parser : CodeVisitor {
var begin = get_location ();
var flags = parse_member_declaration_modifiers ();
expect (TokenType.CONSTRUCT);
if (ModifierFlags.NEW in flags) {
throw new ParseError.SYNTAX (get_error ("`new' modifier not allowed on constructor"));
}
var c = new Constructor (get_src_com (begin));
if (ModifierFlags.STATIC in flags) {
c.binding = MemberBinding.STATIC;
......@@ -2377,6 +2397,9 @@ public class Vala.Parser : CodeVisitor {
parse_identifier ();
expect (TokenType.OPEN_PARENS);
expect (TokenType.CLOSE_PARENS);
if (ModifierFlags.NEW in flags) {
throw new ParseError.SYNTAX (get_error ("`new' modifier not allowed on destructor"));
}
var d = new Destructor (get_src_com (begin));
if (ModifierFlags.STATIC in flags) {
d.binding = MemberBinding.STATIC;
......@@ -2685,6 +2708,10 @@ public class Vala.Parser : CodeVisitor {
next ();
flags |= ModifierFlags.INLINE;
break;
case TokenType.NEW:
next ();
flags |= ModifierFlags.NEW;
break;
case TokenType.OVERRIDE:
next ();
flags |= ModifierFlags.OVERRIDE;
......@@ -2742,6 +2769,9 @@ public class Vala.Parser : CodeVisitor {
var access = parse_access_modifier ();
var flags = parse_member_declaration_modifiers ();
var sym = parse_symbol_name ();
if (ModifierFlags.NEW in flags) {
throw new ParseError.SYNTAX (get_error ("`new' modifier not allowed on creation method"));
}
CreationMethod method;
if (sym.inner == null) {
method = new CreationMethod (sym.name, null, get_src_com (begin));
......@@ -2782,6 +2812,9 @@ public class Vala.Parser : CodeVisitor {
var access = parse_access_modifier ();
var flags = parse_member_declaration_modifiers ();
expect (TokenType.DELEGATE);
if (ModifierFlags.NEW in flags) {
throw new ParseError.SYNTAX (get_error ("`new' modifier not allowed on delegates"));
}
var type = parse_type ();
var sym = parse_symbol_name ();
var type_param_list = parse_type_parameter_list ();
......@@ -2940,6 +2973,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.INTERFACE:
case TokenType.INTERNAL:
case TokenType.NAMESPACE:
case TokenType.NEW:
case TokenType.OVERRIDE:
case TokenType.PRIVATE:
case TokenType.PROTECTED:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment