[stringtemplate-interest] StringTemplate Compiler for .NET
Sam Harwell
sharwell at pixelminegames.com
Sun Mar 22 06:37:06 PDT 2009
Properties of an object are different than the object reference itself.
When evaluating "attribute.(expression)", only one bin is required for
'attribute'. Depending on how "expression" is formed, its leftmost items
of subexpressions may need bins as well.
There are various ways to modify the binning to handle nested lookups,
etc. One possibility is placing a Stack in the bin with attribute values
and precedence levels. Another possibility is using something similar to
vtable lookup, with a "version" attribute specified on the entries that
is incremented when a child template overrides one of its attributes.
The version allows expiration of the entry so children of the template
that were relying on no overrides of that attribute perform a new
recursive attribute lookup.
Attribute names may need mangling of some form during compilation.
I'm sure I'll run into quite a few problems with the nuances as I work
on this. :o I'll have to look into this more.
Sam
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Volkan
Ceylan
Sent: Sunday, March 22, 2009 5:03 AM
To: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] StringTemplate Compiler for .NET
As i understand, you are trying to create a slot (bin) for all
referencable attributes in the template and
its all anonymous subtemplates in its expression tree. As far as i
know, one can access a calculated
property of an object by means of "attribute.(expression)" but
currently there is no way to
access a template attribute whose name is calculated by an expression
like "(expression)".
Unless an idea of "this" special variable is introduced into
StringTemplate, and it is allowed access
an attribute by an expression like this.(expression), your idea of
given a template, list of attributes that
could be accessed is constant is right. So creating a bin for every
possible attribute and accessing attributes
by their predetermined index is possible. This will eliminate the need
for hash tables, and also eliminate
recursive attribute lookups from a subtemplate to the root template.
I'm sure you are aware that same doesn't hold true for formal
arguments (or default arguments it, i0, i, x etc)
and every anonymous template instance should have its own array of
arguments, even though its also
predetermined list of bins. Also it should be noted that if an
anonymous template/subtemplate has a formal
argument it's value takes predence over a possible global attribute
with the same name.
ST is similar to a lets say a javascript program where attributes are
global variables and arguments are
function parameters. Each template instance is a function with
arguments where its a dynamic
subfunction of its enclosing instance as its enclosing instance may
change dynamically for named
template calls.
There may be some problems when PassThroughAttributes is enabled that
you should be aware of.
_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list