本文整理汇总了C#中Galaxy_Editor_2.Compiler.Generated.node.ALvalueExp.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# ALvalueExp.Apply方法的具体用法?C# ALvalueExp.Apply怎么用?C# ALvalueExp.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Galaxy_Editor_2.Compiler.Generated.node.ALvalueExp
的用法示例。
在下文中一共展示了ALvalueExp.Apply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CaseASimpleInvokeExp
public override void CaseASimpleInvokeExp(ASimpleInvokeExp node)
{
PExp expNode = (PExp)node;
PType type = data.ExpTypes[expNode];
if (type is APointerType) type = new ANamedType(new TIdentifier("string"), null);
ALocalLvalue local = new ALocalLvalue(new TIdentifier("tempName", 0, 0));
ALvalueExp exp = new ALvalueExp(local);
PStm stm = Util.GetAncestor<PStm>(node);
AABlock block = (AABlock)stm.Parent();
node.ReplaceBy(exp);
AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
Util.MakeClone(type, data),
new TIdentifier(varName, 0, 0), expNode);
ALocalDeclStm newStm = new ALocalDeclStm(new TSemicolon(";"), localDecl);
block.GetStatements().Insert(block.GetStatements().IndexOf(stm), newStm);
NewStatements.Add(newStm);
data.LvalueTypes[local] = type;
data.ExpTypes[exp] = type;
data.LocalLinks[local] = localDecl;
//localDecl.Apply(this);
exp.Apply(this);
return;
}
示例2: CaseAAssignmentExp
public override void CaseAAssignmentExp(AAssignmentExp node)
{
ALvalueExp replacer = new ALvalueExp(node.GetLvalue());
data.ExpTypes[replacer] = data.LvalueTypes[replacer.GetLvalue()];
node.ReplaceBy(replacer);
replacer.Apply(this);
}
示例3: OutAIncDecExp
public override void OutAIncDecExp(AIncDecExp node)
{
PIncDecOp op = node.GetIncDecOp();
if (!Util.HasAncestor<AABlock>(node))
{
Token token = null;
if (op is APostDecIncDecOp)
token = ((APostDecIncDecOp) op).GetToken();
else if (op is APreDecIncDecOp)
token = ((APreDecIncDecOp)op).GetToken();
else if (op is APostIncIncDecOp)
token = ((APostIncIncDecOp)op).GetToken();
else if (op is APreIncIncDecOp)
token = ((APreIncIncDecOp)op).GetToken();
errors.Add(new ErrorCollection.Error(token, LocRM.GetString("ErrorText114")));
throw new ParserException(token, "TypeChecking.OutAIncDecExp");
}
bool plus = op is APreIncIncDecOp || op is APostIncIncDecOp;
if (op is APreIncIncDecOp || op is APreDecIncDecOp || node.Parent() is AExpStm)
{//++i, --i, i++; or i--;
//Replace with assignment
//<exp>++ => <exp> + 1
//(... foo = <exp> ...)++ => (... foo = <exp> ...) = (... foo ...) + 1
//(... foo++ ...)++ => (... foo++ ...) = (... foo ...) + 1
PLvalue clone = Util.MakeClone(node.GetLvalue(), data);
clone.Apply(new AssignFixup(data));
PBinop binop;
if (plus)
{
binop = new APlusBinop(new TPlus("+"));
}
else
{
binop = new AMinusBinop(new TMinus("-"));
}
ABinopExp addExp = new ABinopExp(new ALvalueExp(clone), binop, new AIntConstExp(new TIntegerLiteral("1")));
AAssignmentExp exp = new AAssignmentExp(new TAssign("="), node.GetLvalue(), addExp);
node.ReplaceBy(exp);
exp.Apply(this);
return;
}
{//i++ or i--
//Make a new local so
//int newLocal = i;
//++i;
//...newLocal...;
PLvalue lvalueClone = Util.MakeClone(node.GetLvalue(), data);
PExp exp = new ALvalueExp(Util.MakeClone(node.GetLvalue(), data));
data.ExpTypes[exp] = data.LvalueTypes[node.GetLvalue()];
AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(data.LvalueTypes[node.GetLvalue()], data), new TIdentifier("incDecVar"), exp);
ALocalDeclStm localDeclStm = new ALocalDeclStm(new TSemicolon(";"), localDecl);
node.SetIncDecOp(plus
? (PIncDecOp) new APreIncIncDecOp(new TPlusPlus("++"))
: new APreDecIncDecOp(new TMinusMinus("--")));
ALocalLvalue lvalue = new ALocalLvalue(new TIdentifier(localDecl.GetName().Text));
exp = new ALvalueExp(lvalue);
data.ExpTypes[exp] = data.LvalueTypes[lvalue] = data.LvalueTypes[node.GetLvalue()];
data.LocalLinks[lvalue] = localDecl;
PStm pStm = Util.GetAncestor<PStm>(node);
node.ReplaceBy(exp);
PStm nodeStm = new AExpStm(new TSemicolon(";"), node);
AABlock block = (AABlock) pStm.Parent();
block.GetStatements().Insert(block.GetStatements().IndexOf(pStm), localDeclStm);
block.GetStatements().Insert(block.GetStatements().IndexOf(pStm), nodeStm);
localDeclStm.Apply(this);
nodeStm.Apply(this);
exp.Apply(this);
if (pStm is AWhileStm && Util.IsAncestor(exp, ((AWhileStm)pStm).GetCondition()))
{
AWhileStm aStm = (AWhileStm)pStm;
//Insert
// newLocal = i
// ++i
//Before each continue in the while, and at the end.
//Add continue statement, if not present
block = (AABlock)((ABlockStm)aStm.GetBody()).GetBlock();
if (block.GetStatements().Count == 0 || !(block.GetStatements()[block.GetStatements().Count - 1] is AContinueStm))
block.GetStatements().Add(new AContinueStm(new TContinue("continue")));
//Get all continue statements in the while
ContinueFinder finder = new ContinueFinder();
block.Apply(finder);
foreach (AContinueStm continueStm in finder.Continues)
{
PLvalue nodeLvalue1 = Util.MakeClone(lvalueClone, data);
PExp nodeLvalue1Exp = new ALvalueExp(nodeLvalue1);
PLvalue nodeLvalue2 = Util.MakeClone(lvalueClone, data);
ALocalLvalue newLocalLvalue = new ALocalLvalue(new TIdentifier("newLocal"));
data.LocalLinks[newLocalLvalue] = localDecl;
AAssignmentExp assignment = new AAssignmentExp(new TAssign("="), newLocalLvalue, nodeLvalue1Exp);
PStm assignmentStm = new AExpStm(new TSemicolon(";"), assignment);
//.........这里部分代码省略.........