Changeset 924


Ignore:
Timestamp:
Jul 1, 2003, 6:38:19 AM (18 years ago)
Author:
orlov
Message:
  • Fixed compilation of $error's.
Location:
to-imperative/trunk/compiler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/rfp_asail.rf

    r881 r924  
    9898      };
    9999    (TRY e.body) =
    100       ('trap {' (<ASAIL-To-CPP e.body>) '}');
     100      ('trap') ('{' (<ASAIL-To-CPP e.body>) '}');
    101101    (CATCH-ERROR e.body) =
    102       ('with {' (<ASAIL-To-CPP e.body>) '}');
     102      ('with') <ASAIL-To-CPP e.body>;
    103103    RETURN = ('return true;');
    104104    RETFAIL = ('retfail;');
     
    205205        <Expr-Int-To-CPP e.pos>   ', ' <Expr-Int-To-CPP e.len> ')';
    206206  (REF t.name) = <Name-To-CPP t.name>;
     207  ERROR-EXPR = 'err';
    207208  (s.var-tag t.name) = <Rfp2Cpp (s.var-tag t.name)>;
    208209};
  • to-imperative/trunk/compiler/rfp_clashes.rf

    r881 r924  
    152152    <Classify-Lengths (s.idx (e.Re) (s.dir e.Pe))> :: e.boxes1,
    153153    /*
    154      * Если e.R1 -- переменная или константа, кладём его в ящик
     154     * Если e.R1 -- переменная или константа, кладём её в ящик
    155155     * &Ready-Source.
    156156     */
  • to-imperative/trunk/compiler/rfp_compile.rf

    r881 r924  
    243243  <Gener-Vars (e.in) "arg"> :: e.in,
    244244  <Vars e.in> :: e.arg-vars,
    245   <Vars-Decl e.arg-vars> : e,
     245  <Vars-Decl e.arg-vars> : e, // ???
    246246  <Map &Set-Var- (Instantiated? True) (e.arg-vars)> : e,
    247247  <Store &Arg-Vars e.arg-vars>,
     
    394394  (s.dir e.Pattern) e.Snt, s.dir : \{ LEFT; RIGHT; } =
    395395    <Get-Clash-Sequence (e.last-Re) e.Sentence> :: (e.clashes) e.Sentence,
    396 //    <WriteLN XXX e.clashes>,
    397396    <Comp-Clashes (e.clashes) s.tail? (v.fails) e.Sentence>;
    398397
     
    415414     * If so, we should declare variables from that expression before
    416415     * entering any branch -- those should be visible after the block.
     416     * Pattern or format expression is placed in the end of each branch.
     417     * But if a branch computes to $error, the expression shouldn't be
     418     * used, so protect it with (Comp If-not-error).
    417419     * If next after the block is (Comp Error) then block results should be
    418420     * used as values for $error, so place (Comp Error) in the end of each
    419421     * branch.
     422     * If next after the block is (Comp If-not-error) then our block is in
     423     * the end of a branch of an outer block and has next pattern or format
     424     * inherited from there.  In that case we should place all the sentence
     425     * rest in the end of each branch because the block can be inside the
     426     * $error already.
    420427     */
    421428    {
     
    432439        <Vars e.expr> :: e.vars,
    433440*                               <New-Vars e.vars>,
    434         (<Vars-Decl e.vars>) (t.first) ((Comp Source)) e.rest;
     441        (<Vars-Decl e.vars>) ((Comp If-not-error) t.first)
     442        ((Comp Source)) e.rest;
    435443      (Comp Error) e.rest =
    436444        () ((Comp Error)) () /*empty*/;
     445      (Comp If-not-error) e.rest =
     446        () (e.Snt) () /*empty*/;
    437447      e = () () () e.Snt;
    438     } :: (e.decls) (e.next-term) (e.source?) e.Snt,
     448    } :: (e.decls) (e.next-terms) (e.source?) e.Snt,
    439449    /*
    440450     * The block is a source if after it goes pattern or format expression
     
    480490          (v.branch-fails ((BREAK t.br-label)))
    481491          (e.last-Re)
    482           e.branch e.next-term
     492          e.branch e.next-terms
    483493        > :: e.comp-br,
    484494        <Recall-Snt-State>,
     
    487497    e.branches : (BRANCH e.branch) =
    488498    <Comp-Sentence
    489       s.tail-branch? (v.branch-fails) (e.last-Re) e.branch e.next-term
     499      s.tail-branch? (v.branch-fails) (e.last-Re) e.branch e.next-terms
    490500    > :: e.last-branch,
    491501    <Pop-Snt-State>,
     
    505515   * Then compile $iter condition and body both with the current state of the
    506516   * sentence.
    507    * e.Snt can contain only (Comp Error), so compile it together with the
     517   * e.Snt can contain (Comp Error) and (protected from errors) pattern or
     518   * format which comes from an outer block, so compile it together with the
    508519   * condition.
    509520   * If condition fails we should compute the body, so put the compiled
     
    527538   * Then recall the state of the sentence and compile catching of an error
    528539   * with a variable err.
    529    * e.Snt can be only (Comp Error), so compile it together with both
    530    * sentences -- when either of it comuptes to an object expression it
    531    * becomes a value of the $error.
     540   * e.Snt can contain (Comp Error) and (protected from errors) pattern or
     541   * format which comes from an outer block, so compile it together with both
     542   * sentences.
    532543   */
    533544  (TRY (BRANCH e.try) e.catch) e.Snt =
     
    535546    <Comp-Sentence Notail ((FATAL)) () e.try e.Snt> :: e.comp-try,
    536547    <Pop-Snt-State>,
    537     <Comp-Sentence s.tail? (v.fails) () (RESULT (EVAR ("err" 0))) e.catch e.Snt>
    538       :: e.comp-catch,
     548    <Gener-Err-Var> :: t.var,
     549    <Set-Var (Instantiated? True) t.var>,
     550    <Comp-Sentence s.tail? (v.fails) (t.var) e.catch e.Snt> :: e.comp-catch,
    539551    (TRY e.comp-try) (CATCH-ERROR e.comp-catch);
    540552
     
    605617    (LABEL (t.label) e.comp-negation) <Comp-Sentence s.tail? (v.fails) () e.Snt>;
    606618
    607 //  (Comp Verbatim expr) = expr;
    608 
    609619  /*
    610620   * In case of $error all fails become $error(Fname "Unexpected fail").  So
     
    614624   */
    615625  (ERROR) e.Snt =
    616     <Comp-Sentence Notail ((FATAL)) e.Snt () (Comp Error)>;
    617 
    618   (Comp Error) e.Snt = (ERROR e.last-Re);
     626    <Comp-Sentence Notail ((FATAL)) () e.Snt (Comp Error)>;
     627
     628  (Comp Error) e.Snt =
     629    <Comp-Static-Exprs (e.last-Re)> : (e.Re),
     630    (ERROR e.Re);
     631
     632  /*
     633   * Protection mark to be used between source and tail.  If there is $error
     634   * construction somewhere in the source then the tail shouldn't be
     635   * computed, but instead the source value should be used for throwing.
     636   */
     637  (Comp If-not-error) e.Snt =
     638    {
     639      e.Snt : e (Comp Error) =
     640        <Comp-Sentence s.tail? (v.fails) (e.last-Re) (Comp Error)>;
     641      <Comp-Sentence s.tail? (v.fails) (e.last-Re) e.Snt>;
     642    };
    619643
    620644//  (Comp Fatal) = FATAL;
    621645
    622646//  (Comp Retfail) = RETFAIL;
    623 
    624   (Comp Fail t.fail) e.Snt = <Comp-Sentence s.tail? (v.fails t.fail) () e.Snt>;
    625647
    626648};
  • to-imperative/trunk/compiler/rfp_vars.rf

    r881 r924  
    232232      (s.tag <Box 1 e.prefix>) <Gener-Vars (e.Fe) e.prefix>;
    233233    };
    234     e.format : (PAREN e1) e2 =
    235       (PAREN <Gener-Vars (e1) e.prefix>) <Gener-Vars (e2) e.prefix>;
     234    e.format : (PAREN v1) e2 =
     235      (PAREN <Gener-Vars (v1) e.prefix>) <Gener-Vars (e2) e.prefix>;
    236236    e.format : t.Ft e.Fe =
    237237      t.Ft <Gener-Vars (e.Fe) e.prefix>;
     
    241241*       <New-Vars e.vars>,
    242242*       (e.vars) e.Re;
     243
     244Gener-Err-Var = (EVAR <Box 2>);
    243245
    244246
     
    282284        <Store s.box t.var>,
    283285        t.var <Boxes-To-Vars expr>;
     286      2 =
     287        ERROR-EXPR <Boxes-To-Vars expr>;
    284288      t.var = <Boxes-To-Vars t.var expr>;
    285289    };
  • to-imperative/trunk/compiler/rfp_vars.rfi

    r759 r924  
    2222
    2323$func Gener-Vars (e.format) e.prefix = /*(e.vars)*/ e.Re;
     24
     25$func Gener-Err-Var = t.var;
    2426
    2527$func? Generated-Var? e.Re = ;
Note: See TracChangeset for help on using the changeset viewer.