public object VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data) { if (currentSwitchTempName == null) { AddError(gotoCaseStatement, "goto case cannot be used outside switch"); return(null); } string labelName; if (gotoCaseStatement.IsDefaultCase) { labelName = "default"; } else { B.Expression expr = ConvertExpression(gotoCaseStatement.Expression); if (expr == null) { return(null); } labelName = expr.ToCodeString().GetHashCode().ToString(System.Globalization.NumberFormatInfo.InvariantInfo); } return(new B.GotoStatement(GetLexicalInfo(gotoCaseStatement), new B.ReferenceExpression(currentSwitchTempName + "_" + labelName))); }
private static string ParameterNameFrom(Expression target) { switch (target.NodeType) { case NodeType.ReferenceExpression: return ((ReferenceExpression) target).Name; case NodeType.SelfLiteralExpression: return "self"; } throw new ArgumentException(target.ToCodeString()); }
public static ParameterDeclaration Lift(Expression e) { if (e == null) return null; switch (e.NodeType) { case NodeType.TryCastExpression: return Lift((TryCastExpression)e); case NodeType.ReferenceExpression: return Lift((ReferenceExpression)e); } throw new NotImplementedException(e.ToCodeString()); }
private static string ParameterNameFrom(Expression target) { switch (target.NodeType) { case NodeType.ReferenceExpression: return(((ReferenceExpression)target).Name); case NodeType.SelfLiteralExpression: return("self"); } throw new ArgumentException(target.ToCodeString()); }
B.TypeReference ConvertTypeReference(B.Expression expr) { B.TypeofExpression te = expr as B.TypeofExpression; if (te != null) { return(te.Type); } if (expr is B.ReferenceExpression) { return(new B.SimpleTypeReference(expr.ToCodeString())); } AddError(expr.LexicalInfo, "Expected type, but found expression."); return(null); }
public static ParameterDeclaration Lift(Expression e) { if (e == null) { return(null); } switch (e.NodeType) { case NodeType.TryCastExpression: return(Lift((TryCastExpression)e)); case NodeType.ReferenceExpression: return(Lift((ReferenceExpression)e)); } throw new NotImplementedException(e.ToCodeString()); }
public static TypeReference Lift(Expression e) { switch (e.NodeType) { case NodeType.TypeofExpression: return(Lift((TypeofExpression)e)); case NodeType.GenericReferenceExpression: return(Lift((GenericReferenceExpression)e)); case Ast.NodeType.ReferenceExpression: return(Lift((ReferenceExpression)e)); case Ast.NodeType.MemberReferenceExpression: return(Lift((MemberReferenceExpression)e)); } throw new NotImplementedException(e.ToCodeString()); }
public static TypeReference Lift(Expression e) { switch (e.NodeType) { case NodeType.TypeofExpression: return Lift((TypeofExpression) e); case NodeType.GenericReferenceExpression: return Lift((GenericReferenceExpression) e); case Ast.NodeType.ReferenceExpression: return Lift((ReferenceExpression) e); case Ast.NodeType.MemberReferenceExpression: return Lift((MemberReferenceExpression) e); } throw new NotImplementedException(e.ToCodeString()); }
public static Expression convertToAttribute(Expression expression){ if (expression is MemberReferenceExpression){ return expression; } if (expression is ReferenceExpression){ if (expression.ToCodeString().StartsWith("@")){ return new ReferenceExpression(expression.ToCodeString().Substring(1)); } else{ return new StringLiteralExpression(expression.ToCodeString()); } } return expression; }
public static AST.Expression when(AST.Expression expr) { AST.BlockExpression condition = new AST.BlockExpression(); condition.Body.Add(new AST.ReturnStatement(expr)); return(new AST.MethodInvocationExpression(new AST.ReferenceExpression("flow_condition"), condition, new AST.StringLiteralExpression(expr.ToCodeString()))); }
protected static AST.Expression multi_instance_split(AST.Expression expr) { AST.BlockExpression condition = new AST.BlockExpression(); condition.Body.Add(new AST.ReturnStatement(expr)); return(new AST.MethodInvocationExpression(new AST.ReferenceExpression("multi_instance_split_expression"), condition, new AST.StringLiteralExpression(expr.ToCodeString()))); }
protected static AST.Expression output_binding(AST.Expression vname, AST.Expression expr) { AST.BlockExpression condition = new AST.BlockExpression(); condition.Body.Add(new AST.ReturnStatement(expr)); return(new AST.MethodInvocationExpression(new AST.ReferenceExpression("add_output_binding"), vname, condition, new AST.StringLiteralExpression(expr.ToCodeString()))); }
protected static AST.Expression task_output_data(AST.Expression expr) { AST.BlockExpression condition = new AST.BlockExpression(); condition.Body.Add(new AST.ReturnStatement(expr)); return(new AST.MethodInvocationExpression(new AST.ReferenceExpression("output_bindings_code"), condition, new AST.StringLiteralExpression(expr.ToCodeString()))); }
public static AST.Expression default_value(AST.Expression expr) { AST.BlockExpression condition = new AST.BlockExpression(); condition.Body.Add(new AST.ReturnStatement(expr)); return(new AST.MethodInvocationExpression(new AST.ReferenceExpression("variable_default"), condition, new AST.StringLiteralExpression(expr.ToCodeString()))); }
public object VisitSwitchSection(SwitchSection switchSection, object data) { B.IfStatement surroundingIf = (B.IfStatement)data; bool isDefault = false; ArrayList conditions = new ArrayList(); ArrayList labels = new ArrayList(); foreach (CaseLabel caseLabel in switchSection.SwitchLabels) { if (caseLabel.IsDefault) { isDefault = true; } else { if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) { AddError(caseLabel, "VB's Case Is currently not supported (Daniel's too lazy for VB stuff)"); } else { B.Expression expr = ConvertExpression(caseLabel.Label); if (expr != null) { conditions.Add(new B.BinaryExpression(B.BinaryOperatorType.Equality, new B.ReferenceExpression(currentSwitchTempName), expr)); string labelName = expr.ToCodeString().GetHashCode().ToString(System.Globalization.NumberFormatInfo.InvariantInfo); labels.Add(MakeLabel(currentSwitchTempName + "_" + labelName)); } } } } B.IfStatement s = null; if (conditions.Count > 0) { s = new B.IfStatement(GetLexicalInfo(switchSection)); if (surroundingIf != null) { s.FalseBlock = surroundingIf.FalseBlock; surroundingIf.FalseBlock = new B.Block(); surroundingIf.FalseBlock.Add(s); } s.TrueBlock = new B.Block(); foreach (B.Statement stmt in labels) { s.TrueBlock.Add(stmt); } B.Expression combined = (B.Expression)conditions[0]; for (int i = 1; i < conditions.Count; i++) { combined = new B.BinaryExpression(B.BinaryOperatorType.Or, combined, (B.Expression)conditions[i]); } s.Condition = combined; foreach (Statement node in switchSection.Children) { AddToBlock(node, s.TrueBlock); } } if (s == null) { s = surroundingIf; } if (isDefault) { if (s.FalseBlock == null) { s.FalseBlock = new B.Block(); } s.FalseBlock.Add(MakeLabel(currentSwitchTempName + "_default")); foreach (Statement node in switchSection.Children) { AddToBlock(node, s.FalseBlock); } } return(s); }