This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CL implementation questions


Hi,

On 1 April 2012 05:10, Per Bothner <per@bothner.com> wrote:
> On 03/31/2012 01:25 PM, Charles Turner wrote:
>> - Its special semantics, i.e. it appears computationally invisible,
>> only making a difference in certain forms.
>>
>> I would modify the reader to check for declarations at the start of
>> each body.
>
> Modifying the reader seems wrong. ÂWhat you need to modify is the
> "rewriter". ÂFor example, for lambda you need to modify or override
> kawa.lang.Lambda.rewriteBody. ÂThat calls Translator.rewrite_body,
> which seems like a good place to hook in declaration-processing.
>
> My first suggestion would be to override rewrite_body method in
> Lisp2Compilation such that it just processes the declare forms,
> and then calls super.rewrite_body. ÂThis might not work, if it
> doesn't you'll know better why not.

I'm struggling to set the type of a Declaration (I assume that's all I
need to do), I'm doing the following in Lisp2Compilation

// decls is e.g '((integer x) (gnu.lists.sequence y))
while (decls != LList.Empty) {
      pair = (Pair) decls;
      x = (LList) pair.getCar();
      // In Lambda, this is a PairWithPosition, but making one doesn't
change the
      // fact that the types aren't being enforced
      Object type = x.get(0);
      Object var = x.get(1);
      decl = this.lexical.get(var);
      decl.setType(new LangExp(type), null);
      decl.setFlag(Declaration.TYPE_SPECIFIED);
      decls = (LList)pair.getCdr();
}

The #setType and #setFlag methods seem to be all that's need to set
the type of variables with :: (cf Lambda), what am I missing here?

Thanks,
Charlie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]