File: ReplaceActive.h

package info (click to toggle)
storm-lang 0.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,100 kB
  • sloc: ansic: 261,471; cpp: 140,438; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (47 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "Code/Var.h"
#include "Code/Operand.h"
#include "Value.h"

namespace storm {
	STORM_PKG(core.lang);

	/**
	 * Interface for replacing active functions.
	 */

	class ReplaceContext;
	class ReplaceTasks;
	class Function;

	// Attempt to replace the code in the function 'code' (assumed to point to a code segment
	// managed by Storm) with the new function 'Function'. Generates thunks as necessary. Returns
	// true on success and false otherwise. May also throw exceptions in case the new function does
	// not compile properly.
	// This function is expected to be called *after* types etc. have been update globally. As such,
	// it does not accound for the type equivalence that was previously computed in a ReplaceContext
	// when doing comparisons (it is not possible to do this, since we compile arbitrary code).
	Bool replaceActiveFunction(const void *oldFn, Function *newFn, ReplaceTasks *tasks);


	/**
	 * Data structure to keep track of which data to move.
	 */
	class DataMove {
		STORM_VALUE;
	public:
		// Variable to copy *from*. Expected to have the right size.
		code::Var source;

		// Target offset in the stack frame. Might not be of the right size.
		code::Operand target;

		// Type to be copied. Used to determine if constructors need to be called.
		Value type;

		// Create.
		STORM_CTOR DataMove(code::Var source, code::Operand target, Value type)
			: source(source), target(target), type(type) {}
	};

}