~matthias-brantner/zorba/bug-863730

« back to all changes in this revision

Viewing changes to src/compiler/expression/expr.cpp

  • Committer: gabipetrovay
  • Date: 2011-09-16 19:36:18 UTC
  • Revision ID: svn-v4:8046edc3-af21-0410-8661-ec7318497eea:trunk/zorba:12098
[3393038] Fixed the assertion failure when a debugger expression was wrapping an updating expression. Now the debugger_expr does not inherit from eval_expr.

Factored out a base expr class (namespace_context_base_expr) for all expression classes that require the namespace binding context.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
SERIALIZABLE_CLASS_VERSIONS(wrapper_expr)
77
77
END_SERIALIZABLE_CLASS_VERSIONS(wrapper_expr)
78
78
 
 
79
SERIALIZABLE_CLASS_VERSIONS(namespace_context_base_expr)
 
80
END_SERIALIZABLE_CLASS_VERSIONS(namespace_context_base_expr)
 
81
 
79
82
SERIALIZABLE_CLASS_VERSIONS(cast_or_castable_base_expr)
80
83
END_SERIALIZABLE_CLASS_VERSIONS(cast_or_castable_base_expr)
81
84
 
366
369
}
367
370
 
368
371
 
 
372
/***************************************************************************//**
 
373
  Base for expression classes that require a namespace context
 
374
********************************************************************************/
 
375
namespace_context_base_expr::namespace_context_base_expr(
 
376
    static_context* sctx,
 
377
    const QueryLoc& loc,
 
378
    expr_kind_t kind,
 
379
    const namespace_context* aNSCtx)
 
380
  :
 
381
  expr(sctx, loc, kind),
 
382
  theNSCtx(const_cast<namespace_context*>(aNSCtx))
 
383
{
 
384
}
 
385
 
 
386
 
 
387
const namespace_context* namespace_context_base_expr::getNSCtx() const
 
388
{
 
389
  return theNSCtx.getp(); 
 
390
}
 
391
 
 
392
 
 
393
void namespace_context_base_expr::serialize(::zorba::serialization::Archiver& ar)
 
394
{
 
395
  serialize_baseclass(ar, (expr*)this);
 
396
  ar & theNSCtx;
 
397
}
 
398
 
369
399
 
370
400
/*******************************************************************************
371
401
  Base for cast, treat, promote, castable, instanceof
401
431
  return theTargetType;
402
432
}
403
433
 
 
434
 
404
435
void cast_or_castable_base_expr::set_target_type(xqtref_t target) 
405
436
{
406
437
  theTargetType = target;
643
674
    static_context* sctx,
644
675
    const QueryLoc& loc,
645
676
    expr_t inputExpr,
646
 
    const namespace_context* aNCtx,
 
677
    const namespace_context* aNSCtx,
647
678
    bool isAttrName)
648
679
  :
649
 
  expr(sctx, loc, name_cast_expr_kind),
 
680
  namespace_context_base_expr(sctx, loc, name_cast_expr_kind, aNSCtx),
650
681
  theInputExpr(inputExpr),
651
 
  theNCtx(const_cast<namespace_context*>(aNCtx)),
652
682
  theIsAttrName(isAttrName)
653
683
{
654
684
  compute_scripting_kind();
659
689
{
660
690
  serialize_baseclass(ar, (expr*)this);
661
691
  ar & theInputExpr;
662
 
  ar & theNCtx;
663
692
  ar & theIsAttrName;
664
693
}
665
694
 
675
704
}
676
705
 
677
706
 
678
 
namespace_context* name_cast_expr::get_namespace_context() const
679
 
{
680
 
  return theNCtx.getp();
681
 
}
682
 
 
683
 
 
684
707
expr_t name_cast_expr::clone(substitution_t& subst) const
685
708
{
686
709
  return new name_cast_expr(theSctx,
687
710
                            get_loc(),
688
711
                            get_input()->clone(subst),
689
 
                            get_namespace_context(),
 
712
                            getNSCtx(),
690
713
                            theIsAttrName);
691
714
}
692
715
 
741
764
    expr_t aContent,
742
765
    const namespace_context* aNSCtx)
743
766
  :
744
 
  expr(sctx, aLoc, elem_expr_kind),
 
767
  namespace_context_base_expr(sctx, aLoc, elem_expr_kind, aNSCtx),
745
768
  theQNameExpr(aQNameExpr),
746
769
  theAttrs(aAttrs),
747
 
  theContent(aContent),
748
 
  theNSCtx(const_cast<namespace_context*>(aNSCtx))
 
770
  theContent(aContent)
749
771
{
750
772
  compute_scripting_kind();
751
773
 
760
782
    expr_t aContent,
761
783
    const namespace_context* aNSCtx)
762
784
  :
763
 
  expr(sctx, aLoc, elem_expr_kind),
 
785
  namespace_context_base_expr(sctx, aLoc, elem_expr_kind, aNSCtx),
764
786
  theQNameExpr(aQNameExpr),
765
787
  theAttrs(0),
766
 
  theContent(aContent),
767
 
  theNSCtx(const_cast<namespace_context*>(aNSCtx))
 
788
  theContent(aContent)
768
789
{
769
790
  compute_scripting_kind();
770
791
 
782
803
}
783
804
 
784
805
 
785
 
const namespace_context* elem_expr::getNSCtx() const
786
 
{
787
 
  return theNSCtx.getp(); 
788
 
}
789
 
 
790
 
 
791
806
void elem_expr::compute_scripting_kind()
792
807
{
793
808
  checkNonUpdating(theQNameExpr);
1377
1392
    expr_script_kind_t scriptingKind,
1378
1393
    namespace_context* nsCtx)
1379
1394
  :
1380
 
  expr(sctx, loc, eval_expr_kind),
 
1395
  namespace_context_base_expr(sctx, loc, eval_expr_kind, nsCtx),
1381
1396
  theExpr(e),
1382
 
  theNSCtx(nsCtx),
1383
1397
  theInnerScriptingKind(scriptingKind)
1384
1398
{
1385
1399
  compute_scripting_kind();
1392
1406
  ar & theExpr;
1393
1407
  ar & theVars;
1394
1408
  ar & theArgs;
1395
 
  ar & theNSCtx;
1396
1409
  SERIALIZE_ENUM(expr_script_kind_t, theInnerScriptingKind);
1397
1410
}
1398
1411
 
1399
1412
 
1400
 
const namespace_context* eval_expr::getNSCtx() const
1401
 
{
1402
 
  return theNSCtx.getp(); 
1403
 
}
1404
 
 
1405
 
 
1406
1413
expr_script_kind_t eval_expr::get_inner_scripting_kind() const 
1407
1414
{
1408
1415
  return theInnerScriptingKind; 
1448
1455
/*******************************************************************************
1449
1456
 
1450
1457
********************************************************************************/
 
1458
debugger_expr::debugger_expr(
 
1459
    static_context* sctx,
 
1460
    const QueryLoc& loc,
 
1461
    expr_t aChild,
 
1462
    std::list<GlobalBinding> aGlobals,
 
1463
    namespace_context* nsCtx,
 
1464
    bool aIsVarDeclaration)
 
1465
  :
 
1466
  namespace_context_base_expr(sctx, loc, debugger_expr_kind, nsCtx),
 
1467
  theExpr(aChild),
 
1468
  theGlobals(aGlobals),
 
1469
  theIsVarDeclaration(aIsVarDeclaration)
 
1470
{
 
1471
  theScriptingKind = aChild->get_scripting_detail();
 
1472
}
 
1473
 
1451
1474
void debugger_expr::store_local_variables(checked_vector<var_expr_t>& aScopedVariables)
1452
1475
{
1453
1476
  std::set<const store::Item*> lQNames;
1468
1491
  }
1469
1492
}
1470
1493
 
 
1494
void debugger_expr::compute_scripting_kind()
 
1495
{
 
1496
}
1471
1497
 
1472
1498
void debugger_expr::serialize(::zorba::serialization::Archiver& ar)
1473
1499
{
1474
 
  serialize_baseclass(ar, (eval_expr*)this);
 
1500
  serialize_baseclass(ar, (expr*)this);
 
1501
  ar & theExpr;
 
1502
  ar & theVars;
 
1503
  ar & theArgs;
1475
1504
  ar & theGlobals;
 
1505
  ar & theIsVarDeclaration;
1476
1506
}
1477
1507
#endif
1478
1508