Questions tagged [trampolines]

A technique to emulate (or augment) jumps / function calls by a custom dispatch. A single trampoline is sufficient to express all control transfers of a program.

A technique to emulate (or augment) jumps / function calls by a custom dispatch to converted functions which return control back to the dispatch (a.k.a. the trampoline) instead of making the function calls themselves, using data to control the control flow.

A single trampoline is sufficient to express all control transfers of a program; a program so expressed is trampolined or in "trampolined style"; converting a program to trampolined style is trampolining. Trampolined functions can be used to implement tail recursive function calls in stack-oriented languages.

See Wikipedia.

71 questions
1
vote
1 answer

Forwarding callback from C++ to ObjC

I am embedding a C++ engine in an ObjC iOS project using a .mm (ObjC++). // consumer.m Wrapper* wrapper = ...; [wrapper setupWithTarget: self selector: @selector(gotData:)]; -(void) gotData: (int) k {...} //wrapper.mm @interface…
P i
  • 29,020
  • 36
  • 159
  • 267
1
vote
1 answer

Scala cats trampoline

The test("ok") is copied from book "scala with cats" by Noel Welsh and Dave Gurnell pag.254 ("D.4 Safer Folding using Eval "), the code run fine, it's the trampolined foldRight import cats.Eval test("ok") { val list = (1 to 100000).toList def…
gekomad
  • 525
  • 9
  • 17
1
vote
1 answer

How to tell apart imported function vs imported global variable in a DLL's PE header?

I'm writing a small tool that should be able to inspect an arbitrary process of interest and check if any of its statically linked functions were trampolined. (An example of a trampoline could be what Microsoft Detours does to a process.) For that I…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
1
vote
0 answers

How to inject DLL into suspended x64 process?

I'm trying to inject my DLL into a 64-bit process that I just created. I initially create it suspended so that I can apply WinAPI patch trampolines in that process (from my injected DLL.) But if I understand it correctly, I cannot inject my DLL into…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
1
vote
3 answers

LLVM Trampoline causing SIGSEGV?

After reading up on generating closures in LLVM using trampolines I tried my hand at compiling some of the examples of trampolines that are floating around the internet (specifically this one). The LLVM IR given in the gist is as follows: declare…
molenzwiebel
  • 886
  • 6
  • 21
1
vote
1 answer

Trampolining scalaz' Monad.whileM_ to prevent stack overflow

I'm using scalaz' Monad.whileM_ to implement a while loop in a functional way as follows: object Main { import scalaz._ import Scalaz._ import scala.language.higherKinds case class IState(s: Int) type IStateT[A] = StateT[Id, IState,…
Martin Studer
  • 2,213
  • 1
  • 18
  • 23
1
vote
1 answer

Trampoline, recursion and lazy evaluation

I'm trying to implement basic lazy sequences in JavaScript. I'm only using closures and continuations. This is what I got so far: var cons = curry(function(x, y, list){ return list(x, y); }); var head = function(seq){ return seq(function(x, y){ …
1
vote
1 answer

How can I tune this trampoline/rubber band object with box2d?

I'm trying to create this trampoline/rubber band using box2d and cocos2d. I got to a point where in my head it should all just work except I don't get the expected effect. My trampoline looks like this: the green objects and the blue one are…
1
vote
1 answer

trampoline unity code not working

So I'm trying to create a realistic trampoline jump instead of the player falling through the trampoline and then slingshotting back up, whilst instead allowing the player to instantly shoot upon contact with the trampoline and come down a relative…
Marc Brooks
  • 369
  • 1
  • 6
  • 15
1
vote
0 answers

Trampoline over Recursion for Array and Object iteration

It's probably just the "Friday after 5:00 and I want to go home" effect, but I'm stumped on this problem. I have a recursive iterator method I'll call each: function canIterate(obj) { return (obj && (typeof obj === 'object' ||…
1
vote
0 answers

How to build a nice generic API for string construction?

In our apps I often need to load images for UI elements like buttons. There are several variants of each image, like landscape/portrait, disabled/enabled, pushed/regular and even colors like white/red/gray. The loading code has some variables that…
zoul
  • 102,279
  • 44
  • 260
  • 354
0
votes
0 answers

Push notifications not working in android 12 after following behavior - changes guide

After updating targeted SDK level 31 from 30 notification getting genarate but on click of notification nothing happens. We are not able to start activity from service class. Document mentions below two solutions but that didn't work Update your…
0
votes
1 answer

Patching arm64 binary to replace all 'call' instructions to point to a specific function

How do I replace all the function calls in an arm64 binary with call to a specific function. The intent is to 'insert' a indirection such that I can log all function calls. Example: mov x29, sp mov w0, #10 bl bar(int) ... # Replace "bl…
A. K.
  • 34,395
  • 15
  • 52
  • 89
0
votes
0 answers

Difference between .rdata and .text section of DLL

I'm trying to write a trampoline function/hook for a misbehaving function in a DLL (Windows, 32 bit, no source available). After failing to do it the "traditional" way, I noticed that the function is a virtual member function of a class and…
mindoverflow
  • 364
  • 1
  • 12
0
votes
1 answer

How to use the Trampoline type as the base monad of a transformer more efficiently?

I have an array transformer type that exhibits interleaved effect layers to ensure a lawful effect implementation. You can easily read the structure from the type's of operation const arrOfT = of => x => of([of(x)]). The type implements an effectful…