public void ExecutesDelegatePerformance() { Dictionary<string, object> vars = new Dictionary<string, object>(5); WaitCallback noop = delegate (object arg) { // noop }; vars["noop"] = noop; FunctionNode fn = new FunctionNode(); fn.Text = "noop"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theArg"; fn.addChild(str); int ITERATIONS = 10000000; StopWatch watch = new StopWatch(); using (watch.Start("Duration Direct: {0}")) { for (int i = 0; i < ITERATIONS; i++) { ((WaitCallback)vars["noop"])(str.getText()); } } using (watch.Start("Duration SpEL: {0}")) { for (int i = 0; i < ITERATIONS; i++) { fn.GetValue(null, vars); } } }
public XmlElement Visit(StringLiteralNode n) { var el = makeNode(n, "string-literal"); addProperty(el, "value", n.Value); return(el); }
public void VisitStringLiteral(StringLiteralNode node) { int index = _strings.Count; _strings.Add(node.Value); int addr = _functionBuilder.AddInstruction(OpCode.PUSHWORD, index); _functionBuilder.SetStringInstruction(addr); }
public void CanCreatePublicInstance() { ConstructorNode ctorNode = new ConstructorNode(typeof(PublicTestClass)); StringLiteralNode sNode = new StringLiteralNode("theValue"); ctorNode.AddArgument(sNode); PublicTestClass instance = (PublicTestClass) ((IExpression)ctorNode).GetValue(); Assert.AreEqual( sNode.Text, instance._s ); Assert.AreEqual( -1, instance._i ); }
public void VisitStringLiteral(StringLiteralNode node) { // Don't insert unreachable code if (!_builder.InsertBlock.IsValid) { return; } _visitedValue = _builder.BuildGlobalStringPtr(node.Value); }
/// <summary> /// Visits the String Literal node. /// </summary> /// <param name="node">The node to visit.</param> public override bool VisitStringLiteral(StringLiteralNode node) { if (node.Parent == null) { return(false); } if (node.Token == null) { return(false); } return(true); }
public void CanCreatePublicInstance() { ConstructorNode ctorNode = new ConstructorNode(typeof(PublicTestClass)); StringLiteralNode sNode = new StringLiteralNode("theValue"); ctorNode.AddArgument(sNode); PublicTestClass instance = (PublicTestClass)((IExpression)ctorNode).GetValue(); Assert.AreEqual(sNode.Text, instance._s); Assert.AreEqual(-1, instance._i); }
public void VisitStringLiteral(StringLiteralNode node) { // String literals are represented as ints, for now. IType?type = _typeManager.GetType("int", PointerMode.NotAPointer); if (type == null) { throw new InvalidOperationException("Primitive types not registered with type system."); } SetAndCacheType(node, type); }
private static LiteralNode FoldTheDreadedAddition(LiteralNode op1, LiteralNode op2) { Interval interval = new Interval(op1.Interval.a, op2.Interval.b); //Aye. IntegerLiteralNode int1 = op1 as IntegerLiteralNode; IntegerLiteralNode int2 = op2 as IntegerLiteralNode; RealLiteralNode rea1 = op1 as RealLiteralNode; RealLiteralNode rea2 = op2 as RealLiteralNode; StringLiteralNode str1 = op1 as StringLiteralNode; StringLiteralNode str2 = op2 as StringLiteralNode; if (int1 != null && int2 != null) { int result = int1.Value + int2.Value; return(CrawlSyntaxNode.IntegerLiteral(interval, CrawlSimpleType.Tal, result)); } if (str1 != null && str2 != null) { string result = str1.Value + str2.Value; return(CrawlSyntaxNode.StringLiteral(interval, CrawlSimpleType.Tekst, result)); } if (rea1 != null && rea2 != null) { double result = rea1.Value + rea2.Value; return(CrawlSyntaxNode.RealLiteral(interval, CrawlSimpleType.Kommatal, result)); } //Hvis de er forskellige, se om a kan tildeles til b, hvis ja, konverter a til b's type //Hvis stadig ikke se om b kan tildeles til a, hvis ja, konverter b til a's type if (str1 != null) { string result = str1.Value + (int2?.Value.ToString() ?? rea2?.Value.ToString(CultureInfo.GetCultureInfo("en-GB"))); return(CrawlSyntaxNode.StringLiteral(interval, CrawlSimpleType.Tekst, result)); } if (str2 != null) { string result = (int1?.Value.ToString() ?? rea1?.Value.ToString(CultureInfo.GetCultureInfo("en-GB"))) + str2.Value; return(CrawlSyntaxNode.StringLiteral(interval, CrawlSimpleType.Tekst, result)); } if (rea1 != null) { double result = rea1.Value + int2.Value; return(CrawlSyntaxNode.RealLiteral(interval, CrawlSimpleType.Kommatal, result)); } if (rea2 != null) { double result = int1.Value + rea2.Value; return(CrawlSyntaxNode.RealLiteral(interval, CrawlSimpleType.Kommatal, result)); } throw new NullReferenceException(); }
public void CanCreatePublicInstanceWithNonPublicConstructor() { ConstructorNode ctorNode = new ConstructorNode(); ctorNode.Text=typeof(PublicTestClass).FullName; StringLiteralNode sNode = new StringLiteralNode(); sNode.Text = "theValue2"; ctorNode.addChild(sNode); IntLiteralNode iNode = new IntLiteralNode(); iNode.Text="2"; ctorNode.addChild(iNode); PublicTestClass instance = (PublicTestClass) ((IExpression)ctorNode).GetValue(); Assert.AreEqual( sNode.Text, instance._s ); Assert.AreEqual( 2, instance._i ); }
public void ExecutesDelegate() { Dictionary<string, object> vars = new Dictionary<string, object>(); vars["concat"] = new TestCallback(Concat); FunctionNode fn = new FunctionNode(); fn.Text = "concat"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theValue"; fn.addChild(str); StringLiteralNode str2 = new StringLiteralNode(); str2.Text = "theValue"; fn.addChild(str2); IExpression exp = fn; Assert.AreEqual(string.Format("{0},{1},{2}", this.GetHashCode(), str.Text, str2.Text), exp.GetValue(null, vars)); }
public void ExecutesLambdaFunction() { Dictionary <string, object> vars = new Dictionary <string, object>(); Expression.RegisterFunction("ident", "{|n| $n}", vars); FunctionNode fn = new FunctionNode(); fn.Text = "ident"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theValue"; fn.addChild(str); IExpression exp = fn; Assert.AreEqual(str.Text, exp.GetValue(null, vars)); }
public void CanCreateNonPublicInstanceWithNonPublicConstructor() { ConstructorNode ctorNode = new ConstructorNode(); ctorNode.Text = typeof(PrivateTestClass).FullName; StringLiteralNode sNode = new StringLiteralNode(); sNode.Text = "theValue3"; ctorNode.addChild(sNode); IntLiteralNode iNode = new IntLiteralNode(); iNode.Text = "3"; ctorNode.addChild(iNode); PublicTestClass instance = (PublicTestClass)((IExpression)ctorNode).GetValue(); Assert.AreEqual(sNode.Text, instance._s); Assert.AreEqual(3, instance._i); }
public void PerformanceOfMethodEvaluationOnDifferentContextTypes() { MethodNode mn = new MethodNode(); mn.Text = "ToString"; TypeNode nln = new TypeNode(); nln.Text = "System.Globalization.CultureInfo"; PropertyOrFieldNode pn = new PropertyOrFieldNode(); pn.Text = "InvariantCulture"; Expression exp = new Expression(); exp.addChild(nln); exp.addChild(pn); StringLiteralNode sln = new StringLiteralNode(); sln.Text = "dummy"; mn.addChild(sln); mn.addChild(exp); IExpression mnExp = mn; Assert.AreEqual("dummy", mnExp.GetValue(0m, null)); int runs = 10000000; StopWatch watch = new StopWatch(); using (watch.Start("Duration: {0}")) { for (int i = 0; i < runs; i++) { mnExp.GetValue(0m, null); } } }
public void ExecutesDelegate() { Dictionary <string, object> vars = new Dictionary <string, object>(); vars["concat"] = new TestCallback(Concat); FunctionNode fn = new FunctionNode(); fn.Text = "concat"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theValue"; fn.addChild(str); StringLiteralNode str2 = new StringLiteralNode(); str2.Text = "theValue"; fn.addChild(str2); IExpression exp = fn; Assert.AreEqual(string.Format("{0},{1},{2}", this.GetHashCode(), str.Text, str2.Text), exp.GetValue(null, vars)); }
public void ExecutesDelegatePerformance() { Dictionary <string, object> vars = new Dictionary <string, object>(5); WaitCallback noop = delegate(object arg) { // noop }; vars["noop"] = noop; FunctionNode fn = new FunctionNode(); fn.Text = "noop"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theArg"; fn.addChild(str); int ITERATIONS = 10000000; StopWatch watch = new StopWatch(); using (watch.Start("Duration Direct: {0}")) { for (int i = 0; i < ITERATIONS; i++) { ((WaitCallback)vars["noop"])(str.getText()); } } using (watch.Start("Duration SpEL: {0}")) { for (int i = 0; i < ITERATIONS; i++) { fn.GetValue(null, vars); } } }
public void Visit(StringLiteralNode node) { builder.AppendLine($"\t\tldstr {EscapeString(node.AnchorToken.Lexeme)}"); }
public void visitStringLiteral(StringLiteralNode node) { this.typeStack.Push(MiniPLTokenType.TYPE_IDENTIFIER_STRING); }
public void ExecutesLambdaFunction() { Dictionary<string, object> vars = new Dictionary<string, object>(); Expression.RegisterFunction("ident", "{|n| $n}", vars); FunctionNode fn = new FunctionNode(); fn.Text = "ident"; StringLiteralNode str = new StringLiteralNode(); str.Text = "theValue"; fn.addChild(str); IExpression exp = fn; Assert.AreEqual(str.Text, exp.GetValue(null, vars)); }
public StringLiteralNodeViewModelBase(StringLiteralNode graphItemObject, uFrame.Editor.GraphUI.ViewModels.DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }
private object EvaluateNode(StringLiteralNode expression, Context context) { return(expression.value); }
public void StrLiteral(IToken token) { var strLitNode = new StringLiteralNode(token); _stack.Push(strLitNode); }
public StringLiteralNodeViewModel(StringLiteralNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }
public void VisitStringLiteral(StringLiteralNode node) { Print($"String Literal ({node.Value})"); }
public Type Visit(StringLiteralNode node) { return(Type.STRING); }
public void VisitStringLiteral(StringLiteralNode node) { StringLiteralVisitor?.Visit(node); }
public void visitStringLiteral(StringLiteralNode node) { this.strType = true; this.strStack.Push(node.getString()); }
protected override CrawlSyntaxNode VisitStringLiteral(StringLiteralNode stringLiteral) { return(stringLiteral.WithResultType(CrawlSimpleType.Tekst)); }
protected override List <AssemblyElement> VisitStringLiteral(StringLiteralNode node) { return(new List <AssemblyElement> { new PushVar(node.Symbol) }); }
public object Visit(StringLiteralNode n, object o) { return(null); }
public void VisitStringLiteral(StringLiteralNode node) { VisitPreOrder(node); VisitPostOrder(node); }
public override object VisitStringLiteral(StringLiteralNode node) { return(node.Token.Value); }
public override Expression VisitStringLiteral(StringLiteralNode node) { return(this.Context.Compiler.LiteralEncodingStrategy.String(this, node.Token.Value)); }
/// <summary> /// Visits the String Literal node. /// </summary> /// <param name="node">The node to visit.</param> public virtual TResult VisitStringLiteral(StringLiteralNode node) { throw new NotImplementedException(); }
public StringLiteralNodeViewModel(StringLiteralNode graphItemObject, DiagramViewModel diagramViewModel) : base(graphItemObject, diagramViewModel) { }