本文整理汇总了C#中PExp.ReplaceBy方法的典型用法代码示例。如果您正苦于以下问题:C# PExp.ReplaceBy方法的具体用法?C# PExp.ReplaceBy怎么用?C# PExp.ReplaceBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PExp
的用法示例。
在下文中一共展示了PExp.ReplaceBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveOut
private void MoveOut(PExp exp, PType type)
{
PStm pStm = Util.GetAncestor<PStm>(exp);
AABlock pBlock = (AABlock)pStm.Parent();
ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier("gppVar"));
ALvalueExp lvalueExp = new ALvalueExp(lvalue);
exp.ReplaceBy(lvalueExp);
AALocalDecl decl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(type, data), new TIdentifier("gppVar"), exp);
pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), new ALocalDeclStm(new TSemicolon(";"), decl));
data.LvalueTypes[lvalue] =
data.ExpTypes[lvalueExp] = decl.GetType();
data.LocalLinks[lvalue] = decl;
}
示例2: TurnDynamic
private AALocalDecl TurnDynamic(PExp exp, AALocalDecl targetDecl, PType type, bool assignBefore = true, bool assignAfter = false, bool makeDelete = true)
{
exp.Apply(mover);
//insert
//<basetype>[]* bulkCopyVar = new <baseType>[<dim>]();
//bulkCopyVar[0] = arg[0];
//bulkCopyVar[1] = arg[1];
//bulkCopyVar[2] = arg[2];
//...
//Invoke(..., bulkCopyVar, ...);
//If we need to clean up after, move the exp to it's own statement.
AALocalDecl newLocal;
if (type is AArrayTempType)
{
AArrayTempType aType = (AArrayTempType) type;
ANewExp newExp = new ANewExp(new TNew("new"), new AArrayTempType(
new TLBracket("["),
Util.MakeClone(aType.GetType(),
data),
Util.MakeClone(aType.GetDimention(), data),
(TIntegerLiteral)
aType.GetIntDim().Clone()),
new ArrayList());
newLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
new APointerType(new TStar("*"),
new ADynamicArrayType(
new TLBracket("["),
Util.MakeClone(aType.GetType(),
data))),
new TIdentifier("bulkCopyVar"),
newExp
);
}
else
{
ANewExp newExp = new ANewExp(new TNew("new"), Util.MakeClone(type, data),
new ArrayList());
newLocal = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
new APointerType(new TStar("*"),
Util.MakeClone(type, data)),
new TIdentifier("bulkCopyVar"),
newExp
);
}
PStm pStm = Util.GetAncestor<PStm>(exp);
AABlock pBlock = (AABlock) pStm.Parent();
pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm),
new ALocalDeclStm(new TSemicolon(";"), newLocal));
PLvalue bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
data.LocalLinks[(ALocalLvalue) bulkCopyRef] = newLocal;
data.LvalueTypes[bulkCopyRef] = newLocal.GetType();
ALvalueExp bulkCopyRefExp;
//if (!(type is AArrayTempType))
{
bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
bulkCopyRef = new APointerLvalue(new TStar("*"), bulkCopyRefExp);
data.ExpTypes[bulkCopyRefExp] = newLocal.GetType();
data.LvalueTypes[bulkCopyRef] = type;
}
if (assignBefore)
{
List<PStm> stms = MakeAssignments(bulkCopyRef, exp, new List<AALocalDecl>() {targetDecl});
foreach (PStm stm in stms)
{
pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm), stm);
}
}
int addStms = 1;
if (assignAfter)
{
bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
data.ExpTypes[bulkCopyRefExp] = data.LvalueTypes[bulkCopyRef];
List<PStm> stms = MakeAssignments(((ALvalueExp)exp).GetLvalue(), bulkCopyRefExp, new List<AALocalDecl>() {targetDecl});
addStms += stms.Count;
foreach (PStm stm in stms)
{
pBlock.GetStatements().Insert(pBlock.GetStatements().IndexOf(pStm) + 1, stm);
}
}
bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
data.LocalLinks[(ALocalLvalue) bulkCopyRef] = newLocal;
data.LvalueTypes[bulkCopyRef] = data.ExpTypes[bulkCopyRefExp] = newLocal.GetType();
exp.ReplaceBy(bulkCopyRefExp);
/*if (formal.GetRef() != null || formal.GetOut() != null)
{
//Get args back
}*/
//Delete object
if (makeDelete)
{
bulkCopyRef = new ALocalLvalue(new TIdentifier("bulkCopyVar"));
bulkCopyRefExp = new ALvalueExp(bulkCopyRef);
//.........这里部分代码省略.........