Check-in [ba413d128b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some reworking of register things to make it easier to do things.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ba413d128bffef9322f3cea9a2f1f31983f9810b
User & Date: stephanie.gawroriski 2019-02-05 20:06:54
Context
2019-02-05
20:39
Corrections to compilation. check-in: a8dff38e8b user: stephanie.gawroriski tags: trunk
20:06
Some reworking of register things to make it easier to do things. check-in: ba413d128b user: stephanie.gawroriski tags: trunk
2019-02-03
17:48
Base for process. check-in: 10a700c260 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/libs/tool-classfile-scrf-compiler/net/multiphasicapps/scrf/compiler/RegisterCodeBuilder.java.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
65
66
67
68
69
70
71

72
73
74
75
76
77

78
79
80

81
82
83
84
85
86
87
88
89
90
91
92
93
94

95
96
97
98
99

100
101

102
103
104
105

106



107
108
109
110
111
112
113

114
115
116

117
118
119


120



121
122
123
124
125
126
127
128
129
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf.compiler;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.scrf.RegisterInstruction;
import net.multiphasicapps.scrf.RegisterInstructionIndex;

/**
 * This is used to build the register based code which is for later execution.
 *
 * @since 2019/01/22
 */
public final class RegisterCodeBuilder
................................................................................
		insts.add(__i);
		return rv;
	}
	
	/**
	 * Adds constant value.
	 *

	 * @param __dest The destination.
	 * @param __v The value to set.
	 * @return The instruction index.
	 * @since 2019/01/24
	 */
	public final int addConst(int __dest, int __v)

	{
		return this.add(new RegisterInstruction(
			RegisterInstructionIndex.CONST, __dest, __v));

	}
	
	/**
	 * Adds constant value (pointer).
	 *
	 * @param __dest The destination.
	 * @param __v The value to set.
	 * @return The instruction index.
	 * @since 2019/01/24
	 */
	public final int addConstPointer(int __dest, long __v)
	{
		return this.add(new RegisterInstruction(
			RegisterInstructionIndex.CONST_POINTER, __dest, __v));

	}
	
	/**
	 * Adds a copy from one register to another.
	 *

	 * @param __from The source.
	 * @param __to The destination.

	 * @return The instruction index.
	 * @since 2019/01/23
	 */
	public final int addCopy(int __from, int __to)

	{



		return this.add(new RegisterInstruction(
			RegisterInstructionIndex.COPY, __from, __to));
	}
	
	/**
	 * Adds a copy pointer from one register to another.
	 *

	 * @param __from The source.
	 * @param __to The destination.
	 * @return The instruction index.

	 * @since 2019/01/23
	 */
	public final int addCopyPointer(int __from, int __to)


	{



		return this.add(new RegisterInstruction(
			RegisterInstructionIndex.COPY_POINTER, __from, __to));
	}
	
	/**
	 * Adds a NOP instruction.
	 *
	 * @return The instruction index.
	 * @since 2019/01/23







|







 







>
|




|
>

<
|
>
|
<
<
<
<
<
<
<
<
<
<
<

<
>





>


>



|
>

>
>
>

|



|

>
|
|
<
>
|

<
>
>

>
>
>

|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
83











84

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

114
115
116

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf.compiler;

import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.scrf.RegisterInstruction;
import net.multiphasicapps.scrf.RegisterInstructionType;

/**
 * This is used to build the register based code which is for later execution.
 *
 * @since 2019/01/22
 */
public final class RegisterCodeBuilder
................................................................................
		insts.add(__i);
		return rv;
	}
	
	/**
	 * Adds constant value.
	 *
	 * @param __t The type of memory to form a constant from.
	 * @param __dest The destination register.
	 * @param __v The value to set.
	 * @return The instruction index.
	 * @since 2019/01/24
	 */
	public final int addConst(MemoryType __t, int __dest, long __v)
		throws NullPointerException
	{

		if (__t == null)
			throw new NullPointerException("NARG");
		











		return this.add(new RegisterInstruction(

			RegisterInstructionType.CONST, __t, __dest, , __v));
	}
	
	/**
	 * Adds a copy from one register to another.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The source.
	 * @param __to The destination.
	 * @throws NullPointerException
	 * @return The instruction index.
	 * @since 2019/01/23
	 */
	public final int addCopy(MemoryType __t, int __from, int __to)
		throws NullPointerException
	{
		if (__t == null)
			throw new NullPointerException("NARG");
		
		return this.add(new RegisterInstruction(
			RegisterInstructionType.COPY, __t, __from, __to));
	}
	
	/**
	 * Adds a load from memory instruction.
	 *
	 * @param __t The type of value to copy.
	 * @param __from The memory source to read from.
	 * @param __to The destination register.

	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/05
	 */

	public final int addLoad(MemoryType __t, MemorySource __from, int __to)
		throws NullPointerException
	{
		if (__t == null || __from == null)
			throw new NullPointerException("NARG");
	
		return this.add(new RegisterInstruction(
			RegisterInstructionType.LOAD, __t, __from, __to));
	}
	
	/**
	 * Adds a NOP instruction.
	 *
	 * @return The instruction index.
	 * @since 2019/01/23

Added runt/libs/tool-scrf/net/multiphasicapps/scrf/MemorySource.java.













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf;

/**
 * This interface represents anything which is sourced in memory, this may be
 * a VTable entry or memory pointer.
 *
 * @since 2019/02/05
 */
public interface MemorySource
{
}

Name change from runt/libs/tool-classfile-scrf-compiler/net/multiphasicapps/scrf/compiler/MemoryType.java to runt/libs/tool-scrf/net/multiphasicapps/scrf/MemoryType.java.

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf.compiler;

import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldReference;

/**
 * This represents the type of memory something uses.


 *
 * @since 2019/02/03
 */
public enum MemoryType
{






	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Pointer. */
	POINTER,
	
	/** End. */
	;
	
	/**
	 * Returns the memory type of the given field.
	 *
	 * @param __f The input field.
	 * @return The memory type used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/03
	 */
	public static MemoryType of(FieldReference __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		return MemoryType.of(__f.memberType());
	}
	
	/**
	 * Returns the memory type of the given field.
	 *
	 * @param __f The input field.
	 * @return The memory type used.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/02/03
	 */
	public static MemoryType of(FieldDescriptor __f)
		throws NullPointerException
	{
		if (__f == null)
			throw new NullPointerException("NARG");
		
		// If an object, treat as pointer
		if (__f.isObject())
			return POINTER;
		
		throw new todo.TODO();
	}
}








|

<
<
<

<
>
>





>
>
>
>
>
>
|


|


|




|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
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







































//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf;




/**

 * This represents a type which is used in memory which will change how
 * something be read or stored.
 *
 * @since 2019/02/03
 */
public enum MemoryType
{
	/** Byte (8-bit). */
	BYTE,
	
	/** Short (16-bit). */
	SHORT,
	
	/** Integer (32-bit). */
	INTEGER,
	
	/** Long (64-bit). */
	LONG,
	
	/** Pointer (varies in size). */
	POINTER,
	
	/** End. */
	;
}







































Added runt/libs/tool-scrf/net/multiphasicapps/scrf/RegisterIndex.java.



























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf;

/**
 * This represents an index to a register.
 *
 * @since 2019/02/05
 */
public final class RegisterIndex
	implements Comparable<RegisterIndex>
{
	/** The register index. */
	protected final int index;
	
	/**
	 * Initializes the index.
	 *
	 * @param __i The index of the register.
	 * @since 2019/02/05
	 */
	public RegisterIndex(int __i)
	{
		this.index = __i;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/05
	 */
	@Override
	public final int compareTo(RegisterIndex __o)
	{
		return this.index - __o.index;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/02/05
	 */
	@Override
	public final boolean equals(Object __o)
	{
		if (this == __o)
			return true;
		
		if (!(__o instanceof RegisterIndex))
			return false;
		
		return this.index == ((RegisterIndex)__o).index;
	}
}

Name change from runt/libs/tool-scrf/net/multiphasicapps/scrf/RegisterInstructionIndex.java to runt/libs/tool-scrf/net/multiphasicapps/scrf/RegisterInstructionType.java.

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
48
49
50

51
52
package net.multiphasicapps.scrf;

/**
 * The index of register instruction operations.
 *
 * @since 2019/01/23
 */
public interface RegisterInstructionIndex
{
	/** No-operation. */
	public static final int NOP =
		0;
	
	/** Copy. */
	public static final int COPY =
		1;
	
	/** Copy pointer. */
	public static final int COPY_POINTER =
		2;
	
	/** Copy long. */
	public static final int COPY_LONG =
		3;
	
	/** Load constant value (int). */
	public static final int CONST =
		4;
	
	/** Load constant value (pointer). */
	public static final int CONST_POINTER =
		5;
	
	/** Load constant value (long). */
	public static final int CONST_LONG =
		6;
	
	/** The number of valid instructions. */
	public static final int NUM_INSTRUCTIONS =
		7;

}








|









|
|


|
|


|
|


<
<
<
<
<
<
<
<


<
>


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
package net.multiphasicapps.scrf;

/**
 * The index of register instruction operations.
 *
 * @since 2019/01/23
 */
public interface RegisterInstructionType
{
	/** No-operation. */
	public static final int NOP =
		0;
	
	/** Copy. */
	public static final int COPY =
		1;
	
	/** Load constant value. */
	public static final int CONST =
		2;
	
	/** Load from memory into a register. */
	public static final int LOAD =
		3;
	
	/** Store from a register to memory. */
	public static final int STORE =
		4;
	








	/** The number of valid instructions. */
	public static final int NUM_INSTRUCTIONS =

		5;
}

Added runt/libs/tool-scrf/net/multiphasicapps/scrf/VTableIndex.java.













































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
//     Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.scrf;

/**
 * This represents an index a VTable for the current class.
 *
 * @since 2019/02/05
 */
public class VTableIndex
	implements MemorySource
{
}