01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.util;
19:
20: public class FastExecutionStack implements Stack {
21: private final Object[] stack = new Object[15];
22: private int size = 0;
23:
24: public boolean isEmpty() {
25: return size == 0;
26: }
27:
28: public Object peek() {
29: return stack[size];
30: }
31:
32: public void push(Object obj) {
33: stack[++size] = obj;
34: }
35:
36: public void add(Object obj) {
37: throw new RuntimeException(
38: "add operation not supported with FastExecutionStack");
39: }
40:
41: public Object pushAndPeek(Object obj) {
42: return stack[++size] = obj;
43: }
44:
45: public void push(Object obj1, Object obj2) {
46: System.out.println("PUSH <<" + obj1 + ">>");
47: System.out.println("PUSH <<" + obj2 + ">>");
48: stack[++size] = obj1;
49: stack[++size] = obj2;
50: }
51:
52: public void push(Object obj1, Object obj2, Object obj3) {
53: stack[++size] = obj1;
54: stack[++size] = obj2;
55: stack[++size] = obj3;
56: }
57:
58: public Object pop() {
59: return stack[size--];
60: }
61:
62: public void discard() {
63: --size;
64: }
65:
66: public void clear() {
67: size = 0;
68: }
69:
70: public int size() {
71: return size;
72: }
73:
74: public void showStack() {
75:
76: }
77: }
|