[
https://issues.apache.org/jira/browse/ETCH-27?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12665591#action_12665591
]
scott comer commented on ETCH-27:
---------------------------------
here's the patch of the fix, tested.
Index:
binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java
===================================================================
---
binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java
(revision 723090)
+++
binding-csharp/compiler/src/main/java/etch/bindings/csharp/compiler/Compiler.java
(working copy)
@@ -269,24 +269,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, what, dir, templateDir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, what, dir, templateDir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Set<String> what, Output dir,
Output templateDir ) throws Exception
{
@@ -856,7 +842,7 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
return n.efqname( this );
}
}
@@ -896,7 +882,7 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
if (n.isEnumx())
return (n.efqname( this ) + "?");
return n.efqname( this );
@@ -1074,7 +1060,7 @@
return "Validator_" + type.type() + ".Get( " +
type.dim()
+ " )";
- Named<?> n = type.getNamed( gIntf );
+ Named<?> n = type.getNamed( type.intf() );
if (n.isBuiltin())
{
Index:
binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java
===================================================================
---
binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java
(revision 723090)
+++
binding-java/compiler/src/main/java/etch/bindings/java/compiler/Compiler.java
(working copy)
@@ -273,24 +273,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, what, dir, templateDir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, what, dir, templateDir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Set<String> what, Output dir,
Output templateDir ) throws Exception
{
@@ -860,7 +846,7 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
return n.efqname( this );
}
}
@@ -900,7 +886,11 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
+ if (n == null)
+ throw new IllegalArgumentException(
String.format(
+ "undefined or ambiguous name at
line %d: %s",
+ t.beginLine, t.image ) );
return n.efqname( this );
}
}
@@ -1054,7 +1044,7 @@
return String.format( "Validator_%s.get( %d )",
type.type(), type.dim() );
- Named<?> n = type.getNamed( gIntf );
+ Named<?> n = type.getNamed( type.intf() );
if (n.isBuiltin())
{
Index:
binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java
===================================================================
--- binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java
(revision 723090)
+++ binding-xml/compiler/src/main/java/etch/bindings/xml/compiler/Compiler.java
(working copy)
@@ -210,24 +210,10 @@
for (Service intf : module)
{
- // TODO flush gIntf
- gIntf = intf;
- try
- {
- generate( intf, dir );
- }
- finally
- {
- // TODO flush gIntf
- gIntf = null;
- }
+ generate( intf, dir );
}
}
- // TODO flush gIntf
- @Deprecated
- private Service gIntf;
-
private void generate( final Service intf, Output dir )
throws Exception
{
@@ -337,7 +323,7 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
String s = n.efqname( this );
if ( ( s == null ) && ( n instanceof Extern ) )
@@ -414,7 +400,7 @@
{
// we have to use a fully qualified name here.
// find the actual type...
- Named<?> n = gIntf.get( t.image );
+ Named<?> n = type.intf().get( t.image );
if ( n.isExtern() )
@@ -552,7 +538,7 @@
if (type.isBuiltin())
return "Validator_"+type.type()+".get(
"+type.dim()+" )";
- return "Validator_custom.getCustom( "+type.getNamed(
gIntf ).efqname( this )+".class, "+type.dim()+" )";
+ return "Validator_custom.getCustom( "+type.getNamed(
type.intf() ).efqname( this )+".class, "+type.dim()+" )";
}
if (named instanceof Thrown)
Index: compiler/src/main/java/etch/compiler/ast/Service.java
===================================================================
--- compiler/src/main/java/etch/compiler/ast/Service.java (revision
723090)
+++ compiler/src/main/java/etch/compiler/ast/Service.java (working copy)
@@ -250,7 +250,7 @@
Token rmType = new Token();
rmType.kind = EtchGrammarConstants.VOID;
rmType.image = "void";
- TypeRef rmTypeRef = new TypeRef( rmType );
+ TypeRef rmTypeRef = new TypeRef( this, rmType );
nameList.check( rmName );
Message rm = new Message( this, rmName, new HashMap<String,
Opt>(),
Index: compiler/src/main/java/etch/compiler/ast/TypeRef.java
===================================================================
--- compiler/src/main/java/etch/compiler/ast/TypeRef.java (revision
723090)
+++ compiler/src/main/java/etch/compiler/ast/TypeRef.java (working copy)
@@ -28,17 +28,29 @@
{
/**
* Constructs the TypeRef.
+ * @param intf
*
* @param type
*/
- public TypeRef( Token type )
+ public TypeRef( Service intf, Token type )
{
+ this.intf = intf;
this.type = type;
}
+ private final Service intf;
+
private final Token type;
/**
+ * @return the parent object of this reference.
+ */
+ public Service intf()
+ {
+ return intf;
+ }
+
+ /**
* @return the token of the type.
*/
public Token type()
Index: compiler/src/main/javacc/EtchGrammar.jj
===================================================================
--- compiler/src/main/javacc/EtchGrammar.jj (revision 723090)
+++ compiler/src/main/javacc/EtchGrammar.jj (working copy)
@@ -47,6 +47,8 @@
}
private Backend binding;
+
+ private Service gintf;
}
PARSER_END(EtchGrammar)
@@ -156,9 +158,12 @@
i = m.addService( n, opts );
serviceComment( i, getComment() );
binding.addDefaults( i );
+ Service ointf = gintf;
+ gintf = i;
}
<LBRACE> stmts( i ) <RBRACE>
{
+ gintf = ointf;
doEndService( i );
}
}
@@ -406,7 +411,7 @@
| t = <DOUBLE>
| t = <STRING>
)
- { return new TypeRef( t ); }
+ { return new TypeRef( gintf, t ); }
}
TypeRef ptype() :
@@ -414,8 +419,8 @@
{
(
tr = ctype()
- | t = <OBJECT> { tr = new TypeRef( t ); }
- | t = ref() { tr = new TypeRef( t ); }
+ | t = <OBJECT> { tr = new TypeRef( gintf, t ); }
+ | t = ref() { tr = new TypeRef( gintf, t ); }
)
{ return tr; }
}
@@ -425,7 +430,7 @@
{
(
( tr = ptype() d = dim() { tr.setDim( d ); } )
- | t = <VOID> { tr = new TypeRef( t ); }
+ | t = <VOID> { tr = new TypeRef( gintf, t ); }
)
{ return tr; }
}
> mixins cause trouble when two or more mixed in files define a type with the
> same name.
> --------------------------------------------------------------------------------------
>
> Key: ETCH-27
> URL: https://issues.apache.org/jira/browse/ETCH-27
> Project: Etch
> Issue Type: Bug
> Components: compiler, csharp-binding, java-binding
> Affects Versions: 1.0.1
> Reporter: scott comer
> Assignee: scott comer
>
> three etch files, Foo.etch, Bar.etch, Baz.etch.
> Foo mixes in Bar and Baz.
> Bar and Baz each define a struct Entry ( int x ).
> Bar defines a message void barGet( Entry e )
> Baz defines a message void bazGet( Entry e )
> when you compile Foo the compiler fails because it conducts it search for
> type Entry from the top down instead of the bottom up. a top down search
> finds two definitions for Entry. the reference is ambigous and therefore not
> allowed.
> a bottom up search guarantees that barGet binds to Bar's Entry and bazGet
> binds to Baz's Entry.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.