本文整理汇总了C#中PExp类的典型用法代码示例。如果您正苦于以下问题:C# PExp类的具体用法?C# PExp怎么用?C# PExp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PExp类属于命名空间,在下文中一共展示了PExp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FoldInt
private int FoldInt(PExp exp, ref bool valid)
{
if (!valid) return -1;
if (exp is AIntConstExp)
{
return int.Parse(((AIntConstExp) exp).GetIntegerLiteral().Text);
}
if (exp is ABinopExp)
{
ABinopExp aExp = (ABinopExp)exp;
int left = FoldInt(aExp.GetLeft(), ref valid);
int right = FoldInt(aExp.GetLeft(), ref valid);
if (!valid) return -1;
PBinop binop = aExp.GetBinop();
if (binop is APlusBinop)
return left + right;
if (binop is AMinusBinop)
return left - right;
if (binop is ATimesBinop)
return left * right;
if ((binop is AModuloBinop || binop is ADivideBinop) && right == 0)
{
Token token = binop is AModuloBinop
? (Token)((AModuloBinop) binop).GetToken()
: ((ADivideBinop) binop).GetToken();
errors.Add(new ErrorCollection.Error(token, LocRM.GetString("ErrorText57")));
throw new ParserException(null, null);
}
if (binop is AModuloBinop)
return left % right;
if (binop is ADivideBinop)
return left / right;
if (binop is AAndBinop)
return left & right;
if (binop is AOrBinop)
return left | right;
if (binop is AXorBinop)
return left ^ right;
if (binop is ALBitShiftBinop)
return left << right;
if (binop is ARBitShiftBinop)
return left >> right;
}
if (exp is ALvalueExp)
return FoldInt(((ALvalueExp) exp).GetLvalue(), ref valid);
valid = false;
return -1;
}
示例2: IsConst
static bool IsConst(PExp exp, out bool value)
{
if (exp is ABooleanConstExp)
{
value = ((ABooleanConstExp)exp).GetBool() is ATrueBool;
return true;
}
if (exp is AIntConstExp)
{
value = ((AIntConstExp)exp).GetIntegerLiteral().Text != "0";
return true;
}
if (exp is ANullExp)
{
value = false;
return true;
}
value = false;
return false;
}
示例3: SetInit
public void SetInit(PExp node)
{
if (_init_ != null)
{
_init_.Parent(null);
}
if (node != null)
{
if (node.Parent() != null)
{
node.Parent().RemoveChild(node);
}
node.Parent(this);
}
_init_ = node;
}
示例4: SetCondition
public void SetCondition(PExp node)
{
if (_condition_ != null)
{
_condition_.Parent(null);
}
if (node != null)
{
if (node.Parent() != null)
{
node.Parent().RemoveChild(node);
}
node.Parent(this);
}
_condition_ = node;
}
示例5: AIfThenStm
public AIfThenStm(
TLParen _token_,
PExp _condition_,
PStm _body_
)
{
SetToken(_token_);
SetCondition(_condition_);
SetBody(_body_);
}
示例6: SetElse
public void SetElse(PExp node)
{
if (_else_ != null)
{
_else_.Parent(null);
}
if (node != null)
{
if (node.Parent() != null)
{
node.Parent().RemoveChild(node);
}
node.Parent(this);
}
_else_ = node;
}
示例7: SetReceiver
public void SetReceiver(PExp node)
{
if (_receiver_ != null)
{
_receiver_.Parent(null);
}
if (node != null)
{
if (node.Parent() != null)
{
node.Parent().RemoveChild(node);
}
node.Parent(this);
}
_receiver_ = node;
}
示例8: ADelegateInvokeExp
public ADelegateInvokeExp(
TIdentifier _token_,
PExp _receiver_,
IList _args_
)
{
SetToken(_token_);
SetReceiver(_receiver_);
this._args_ = new TypedList(new Args_Cast(this));
this._args_.Clear();
this._args_.AddAll(_args_);
}
示例9: AALocalDecl
public AALocalDecl(
PVisibilityModifier _visibility_modifier_,
TStatic _static_,
TRef _ref_,
TOut _out_,
TConst _const_,
PType _type_,
TIdentifier _name_,
PExp _init_
)
{
SetVisibilityModifier(_visibility_modifier_);
SetStatic(_static_);
SetRef(_ref_);
SetOut(_out_);
SetConst(_const_);
SetType(_type_);
SetName(_name_);
SetInit(_init_);
}
示例10: ACastExp
public ACastExp(
TLParen _token_,
PType _type_,
PExp _exp_
)
{
SetToken(_token_);
SetType(_type_);
SetExp(_exp_);
}
示例11: AForStm
public AForStm(
TLParen _token_,
PStm _init_,
PExp _cond_,
PStm _update_,
PStm _body_
)
{
SetToken(_token_);
SetInit(_init_);
SetCond(_cond_);
SetUpdate(_update_);
SetBody(_body_);
}
示例12: AIfExp
public AIfExp(
TQuestionmark _token_,
PExp _cond_,
PExp _then_,
PExp _else_
)
{
SetToken(_token_);
SetCond(_cond_);
SetThen(_then_);
SetElse(_else_);
}
示例13: ADeleteStm
public ADeleteStm(
TDelete _token_,
PExp _exp_
)
{
SetToken(_token_);
SetExp(_exp_);
}
示例14: SetThen
public void SetThen(PExp node)
{
if (_then_ != null)
{
_then_.Parent(null);
}
if (node != null)
{
if (node.Parent() != null)
{
node.Parent().RemoveChild(node);
}
node.Parent(this);
}
_then_ = node;
}
示例15: AEnrichmentDecl
public AEnrichmentDecl(
TEnrichment _token_,
PExp _dimention_,
TIntegerLiteral _int_dim_,
TRBrace _end_token_,
PType _type_,
IList _decl_
)
{
SetToken(_token_);
SetDimention(_dimention_);
SetIntDim(_int_dim_);
SetEndToken(_end_token_);
SetType(_type_);
this._decl_ = new TypedList(new Decl_Cast(this));
this._decl_.Clear();
this._decl_.AddAll(_decl_);
}