Search in sources :

Example 11 with TraceInfo

use of php.runtime.env.TraceInfo in project jphp by jphp-compiler.

the class CompileFunctionEntity method invoke.

@Override
public Memory invoke(Environment env, TraceInfo trace, Memory[] arguments) throws Throwable {
    CompileFunction.Method method = getCompileFunction().find(arguments.length);
    if (method == null) {
        env.warning(trace, Messages.ERR_EXPECT_LEAST_PARAMS.fetch(name, compileFunction.getMinArgs(), arguments.length));
        return Memory.NULL;
    } else {
        if (arguments.length > method.argsCount && !method.isVarArg()) {
            env.warning(trace, Messages.ERR_EXPECT_EXACTLY_PARAMS, name, method.argsCount, arguments.length);
            return Memory.NULL;
        }
    }
    Class<?>[] types = method.parameterTypes;
    Object[] passed = new Object[types.length];
    int i = 0;
    int j = 0;
    for (Class<?> clazz : types) {
        boolean isRef = method.references[i];
        boolean mutableValue = method.mutableValues[i];
        MemoryUtils.Converter<?> converter = method.converters[i];
        if (clazz == Memory.class) {
            Memory argument = arguments[j];
            passed[i] = isRef ? argument : (mutableValue ? argument.toImmutable() : argument.toValue());
            j++;
        } else if (converter != null) {
            passed[i] = converter.run(arguments[j]);
            j++;
        } else if (clazz == Environment.class) {
            passed[i] = env;
        } else if (clazz == TraceInfo.class) {
            passed[i] = trace;
        } else if (i == types.length - 1 && types[i] == Memory[].class) {
            Memory[] arg = new Memory[arguments.length - i + 1];
            if (!isRef) {
                for (int k = 0; k < arg.length; k++) arg[i] = arguments[i].toImmutable();
            } else {
                System.arraycopy(arguments, j, arg, 0, arg.length);
            }
            passed[i] = arg;
            break;
        } else {
            env.error(trace, ErrorType.E_CORE_ERROR, name + "(): Cannot call this function dynamically");
            passed[i] = Memory.NULL;
        }
        i++;
    }
    try {
        if (method.resultType == void.class) {
            method.method.invoke(null, passed);
            return Memory.NULL;
        } else
            return MemoryUtils.valueOf(method.method.invoke(null, passed));
    } catch (InvocationTargetException e) {
        return env.__throwException(e);
    }
}
Also used : Memory(php.runtime.Memory) CompileFunction(php.runtime.ext.support.compile.CompileFunction) TraceInfo(php.runtime.env.TraceInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) MemoryUtils(php.runtime.memory.support.MemoryUtils)

Example 12 with TraceInfo

use of php.runtime.env.TraceInfo in project jphp by jphp-compiler.

the class ExpressionStmtCompiler method writePushCompileFunction.

Memory writePushCompileFunction(CallExprToken function, CompileFunction compileFunction, boolean returnValue, boolean writeOpcode, PushCallStatistic statistic) {
    CompileFunction.Method method = compileFunction.find(function.getParameters().size());
    if (method == null) {
        if (!writeOpcode)
            return Memory.NULL;
        writeWarning(function, Messages.ERR_EXPECT_LEAST_PARAMS.fetch(compileFunction.name, compileFunction.getMinArgs(), function.getParameters().size()));
        if (returnValue)
            writePushNull();
        return null;
    } else if (!method.isVarArg() && method.argsCount < function.getParameters().size()) {
        if (!writeOpcode)
            return Memory.NULL;
        writeWarning(function, Messages.ERR_EXPECT_EXACTLY_PARAMS.fetch(compileFunction.name, method.argsCount, function.getParameters().size()));
        if (returnValue)
            writePushNull();
        return null;
    }
    if (statistic != null)
        statistic.returnType = StackItem.Type.valueOf(method.resultType);
    Class[] types = method.parameterTypes;
    ListIterator<ExprStmtToken> iterator = function.getParameters().listIterator();
    Object[] arguments = new Object[types.length];
    int j = 0;
    boolean immutable = method.isImmutable;
    boolean init = false;
    for (int i = 0; i < method.parameterTypes.length; i++) {
        Class<?> argType = method.parameterTypes[i];
        boolean isRef = method.references[i];
        boolean isMutable = method.isPresentAnnotationOfParam(i, Runtime.MutableValue.class);
        if (method.isPresentAnnotationOfParam(i, Runtime.GetLocals.class)) {
            if (!writeOpcode)
                return null;
            immutable = false;
            writePushLocal();
        } else if (argType == Environment.class) {
            if (immutable) {
                arguments[i] = compiler.getEnvironment();
            } else {
                if (!writeOpcode)
                    return null;
                writePushEnv();
            }
        } else if (argType == TraceInfo.class) {
            if (immutable) {
                arguments[i] = function.toTraceInfo(compiler.getContext());
            } else {
                if (!writeOpcode)
                    return null;
                writePushTraceInfo(function);
            }
        } else {
            if (argType == Memory[].class) {
                Memory[] args = new Memory[function.getParameters().size() - j];
                boolean arrCreated = false;
                for (int t = 0; t < function.getParameters().size() - j; t++) {
                    ExprStmtToken next = iterator.next();
                    if (immutable)
                        args[t] = writeExpression(next, true, true, false);
                    if (args[t] == null) {
                        if (!writeOpcode)
                            return null;
                        if (!arrCreated) {
                            if (immutable) {
                                for (int n = 0; n < i; /*j*/
                                n++) {
                                    if (arguments[n] instanceof TraceInfo) {
                                        writePushTraceInfo(function);
                                    } else if (arguments[n] instanceof Environment) {
                                        writePushEnv();
                                    } else {
                                        writePushMemory((Memory) arguments[n]);
                                        writePop(types[n], true, true);
                                        arguments[t] = null;
                                    }
                                }
                            }
                            // create new array
                            writePushSmallInt(args.length);
                            code.add(new TypeInsnNode(ANEWARRAY, Type.getInternalName(Memory.class)));
                            stackPop();
                            stackPush(Memory.Type.REFERENCE);
                            arrCreated = true;
                        }
                        writePushDup();
                        writePushSmallInt(t);
                        writeExpression(next, true, false, writeOpcode);
                        // if (!isRef)  BUGFIX - array is memory[] and so we need to convert value to memory
                        writePopBoxing(!isRef);
                        code.add(new InsnNode(AASTORE));
                        stackPop();
                        stackPop();
                        stackPop();
                        immutable = false;
                    }
                }
                if (!immutable && !arrCreated) {
                    code.add(new InsnNode(ACONST_NULL));
                    stackPush(Memory.Type.REFERENCE);
                }
                arguments[i] = MemoryUtils.valueOf(args);
            } else {
                ExprStmtToken next = iterator.next();
                if (!immutable && !init) {
                    init = true;
                    for (int k = 0; k < i; /*j*/
                    k++) {
                        if (arguments[k] != null) {
                            if (arguments[k] instanceof TraceInfo) {
                                writePushTraceInfo(function);
                            } else if (arguments[k] instanceof Environment) {
                                writePushEnv();
                            } else {
                                writePushMemory((Memory) arguments[k]);
                                writePop(types[k], true, isRef);
                                arguments[k] = null;
                            }
                        }
                    }
                }
                if (immutable)
                    arguments[i] = writeExpression(next, true, true, false);
                if (arguments[i] == null) {
                    if (!writeOpcode)
                        return null;
                    if (!init) {
                        for (int n = 0; n < i; /*j*/
                        n++) {
                            if (arguments[n] instanceof TraceInfo) {
                                writePushTraceInfo(function);
                            } else if (arguments[n] instanceof Environment) {
                                writePushEnv();
                            } else {
                                writePushMemory((Memory) arguments[n]);
                                writePop(types[n], true, false);
                            }
                            arguments[n] = null;
                        }
                        init = true;
                    }
                    if (isRef)
                        writeExpression(next, true, false, writeOpcode);
                    else {
                        Memory tmp = writeExpression(next, true, true, true);
                        if (tmp != null)
                            writePushMemory(tmp);
                    }
                    writePop(argType, true, isMutable && !isRef);
                    if (!isMutable && !isRef && stackPeek().type.isReference()) {
                        writeSysDynamicCall(Memory.class, "toValue", Memory.class);
                    }
                    immutable = false;
                }
                j++;
            }
        }
    }
    if (immutable) {
        if (!returnValue)
            return null;
        Object[] typedArguments = new Object[arguments.length];
        for (int i = 0; i < arguments.length; i++) {
            if (method.parameterTypes[i] != Memory.class && arguments[i] instanceof Memory)
                typedArguments[i] = method.converters[i].run((Memory) arguments[i]);
            else
                // MemoryUtils.toValue((Memory)arguments[i], types[i]);
                typedArguments[i] = arguments[i];
        }
        try {
            Object value = method.method.invoke(null, typedArguments);
            return MemoryUtils.valueOf(value);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e.getCause());
        }
    }
    if (!writeOpcode)
        return null;
    this.method.entity.setImmutable(false);
    writeLineNumber(function);
    writePushStaticCall(method.method);
    if (returnValue) {
        if (method.resultType == void.class)
            writePushNull();
        setStackPeekAsImmutable();
    }
    return null;
}
Also used : UndefinedMemory(php.runtime.memory.helper.UndefinedMemory) Memory(php.runtime.Memory) CompileFunction(php.runtime.ext.support.compile.CompileFunction) TraceInfo(php.runtime.env.TraceInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) Runtime(php.runtime.annotation.Runtime) Environment(php.runtime.env.Environment) CompileClass(php.runtime.ext.support.compile.CompileClass) IObject(php.runtime.lang.IObject)

Example 13 with TraceInfo

use of php.runtime.env.TraceInfo in project jphp by jphp-compiler.

the class ConstantDumper method load.

@Override
public ConstantEntity load(InputStream input) throws IOException {
    DumpInputStream dump = new DumpInputStream(input);
    String docComment = dump.readUTF();
    boolean cs = dump.readBoolean();
    Modifier modifier = dump.readModifier();
    String name = dump.readName();
    TraceInfo trace = dump.readTrace(context);
    Memory value = dump.readMemory();
    ConstantEntity entity = new ConstantEntity(name, value, cs);
    entity.setContext(context);
    entity.setTrace(trace);
    entity.setModifier(modifier);
    if (!docComment.isEmpty()) {
        entity.setDocComment(new DocumentComment(docComment));
    }
    dump.readRawData();
    return entity;
}
Also used : DumpInputStream(php.runtime.loader.dump.io.DumpInputStream) DocumentComment(php.runtime.reflection.DocumentComment) Memory(php.runtime.Memory) TraceInfo(php.runtime.env.TraceInfo) Modifier(php.runtime.common.Modifier) ConstantEntity(php.runtime.reflection.ConstantEntity)

Example 14 with TraceInfo

use of php.runtime.env.TraceInfo in project jphp by jphp-compiler.

the class Tokenizer method readString.

protected ValueExprToken readString(StringExprToken.Quote quote, int startPosition, int startLine) {
    int i = currentPosition + 1, pos = relativePosition + 1;
    StringExprToken.Quote ch_quote = null;
    boolean slash = false;
    StringBuilder sb = new StringBuilder();
    boolean isMagic = quote != null && quote.isMagic();
    String endString = null;
    int startIndex = currentPosition + 1;
    if (quote == StringExprToken.Quote.DOC) {
        StringBuilder tmp = new StringBuilder();
        StringExprToken.Quote docType = null;
        for (; i < codeLength; i++) {
            char ch = code.charAt(i);
            pos++;
            if (docType == null && TokenizeGrammarUtils.isQuote(ch) != null) {
                docType = TokenizeGrammarUtils.isQuote(ch);
            } else if (docType != null && docType == TokenizeGrammarUtils.isQuote(ch)) {
                if (i + 1 >= codeLength || !TokenizeGrammarUtils.isNewline(code.charAt(i + 1))) {
                    throw new ParseException(Messages.ERR_PARSE_UNEXPECTED_END_OF_STRING.fetch(), new TraceInfo(context, currentLine, currentLine, pos + 1, pos + 1));
                }
                i += 1;
                break;
            // nop
            } else if (tmp.length() == 0 && (ch == ' ' || ch == '\t')) {
            // nop
            } else if (TokenizeGrammarUtils.isEngLetter(ch) || ch == '_' || (tmp.length() != 0 && Character.isDigit(ch))) {
                tmp.append(ch);
            } else if (tmp.length() > 0 && checkNewLine(ch)) {
                pos = 0;
                break;
            } else {
                String error = Messages.ERR_PARSE_UNEXPECTED_X.fetch(ch);
                if (TokenizeGrammarUtils.isNewline(ch))
                    error = Messages.ERR_PARSE_UNEXPECTED_END_OF_STRING.fetch();
                throw new ParseException(error, new TraceInfo(context, currentLine, currentLine, pos, pos));
            }
        }
        currentPosition = i;
        // skip \n
        i += 1;
        isMagic = (docType == null || docType.isMagic());
        endString = tmp.toString();
    }
    List<StringExprToken.Segment> segments = new ArrayList<StringExprToken.Segment>();
    for (; i < codeLength; i++) {
        char ch = code.charAt(i);
        pos++;
        ch_quote = TokenizeGrammarUtils.isQuote(ch);
        if (endString == null && (ch_quote == quote && !slash)) {
            currentPosition = i;
            relativePosition = pos;
            break;
        }
        if (checkNewLine(ch)) {
            pos = 0;
            if (endString != null) {
                int end = i + 1 + endString.length();
                if (end < codeLength) {
                    if (code.substring(i + 1, end).equals(endString)) {
                        if ((code.charAt(end) == ';' && TokenizeGrammarUtils.isNewline(code.charAt(end + 1))) || TokenizeGrammarUtils.isNewline(code.charAt(end))) {
                            currentPosition = i + endString.length();
                            relativePosition = endString.length();
                            ch_quote = StringExprToken.Quote.DOC;
                            break;
                        }
                    }
                }
            }
        }
        if (!isMagic) {
            switch(ch) {
                case '\\':
                    if (!slash || endString != null)
                        sb.append(ch);
                    slash = !slash;
                    break;
                case '\'':
                    if (endString == null)
                        // remove slash
                        sb.deleteCharAt(sb.length() - 1);
                default:
                    sb.append(ch);
                    slash = false;
            }
        } else {
            int dynamic = 0;
            if (!slash) {
                if (ch == '$' && (i + 1 < codeLength && code.charAt(i + 1) == '{')) {
                    dynamic = 2;
                }
                if (ch == '{' && (i + 1 < codeLength && code.charAt(i + 1) == '$'))
                    dynamic = 1;
            }
            if (dynamic > 0) {
                if (dynamic == 2 || i + 1 < codeLength && code.charAt(i + 1) == '$') {
                    slash = false;
                    int opened = dynamic == 2 ? 0 : 1;
                    int j;
                    for (j = i + 1; j < codeLength; j++) {
                        switch(code.charAt(j)) {
                            case '{':
                                opened++;
                                break;
                            case '}':
                                opened--;
                                break;
                        }
                        checkNewLine(code.charAt(j));
                        if (opened == 0)
                            break;
                    }
                    if (opened != 0)
                        throw new ParseException(Messages.ERR_PARSE_UNEXPECTED_END_OF_STRING.fetch(), new TraceInfo(context, startLine, 0, relativePosition, 0));
                    String sub = code.substring(i, j + 1);
                    segments.add(new StringExprToken.Segment(sb.length(), sb.length() + sub.length(), dynamic == 2));
                    /*segments.add(new StringExprToken.Segment(
                                i - currentPosition - 1, j - currentPosition, dynamic == 2
                        ));*/
                    sb.append(sub);
                    i = j;
                    continue;
                }
            }
            if (slash) {
                switch(ch) {
                    case 'r':
                        sb.append('\r');
                        slash = false;
                        break;
                    case 'n':
                        sb.append('\n');
                        slash = false;
                        break;
                    case 't':
                        sb.append('\t');
                        slash = false;
                        break;
                    case 'e':
                        sb.append((char) 0x1B);
                        slash = false;
                        break;
                    case 'v':
                        sb.append((char) 0x0B);
                        slash = false;
                        break;
                    case 'f':
                        sb.append('\f');
                        slash = false;
                        break;
                    case '\\':
                        sb.append(ch);
                        slash = !slash;
                        break;
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                        // \[0-7]{1,3}
                        int k = i + 1;
                        for (int j = 1; j < 3; j++) {
                            k = i + j;
                            if (k < codeLength) {
                                char digit = code.charAt(k);
                                if (digit >= '0' && digit <= '7') {
                                // nop
                                } else
                                    break;
                            } else
                                break;
                        }
                        String s = code.substring(i, k);
                        if (s.isEmpty()) {
                            sb.append(ch);
                        } else {
                            int val = Integer.parseInt(s, 8);
                            sb.append((char) val);
                        }
                        i = k - 1;
                        slash = false;
                        break;
                    case 'x':
                        int t = i + 1;
                        for (int j = 1; j < 5; j++) {
                            t = i + j;
                            if (t < codeLength) {
                                char digit = code.charAt(t);
                                if (Character.isDigit(digit) || (digit >= 'A' && digit <= 'F') || (digit >= 'a' && digit <= 'f')) {
                                // nop;
                                } else {
                                    break;
                                }
                            } else
                                break;
                        }
                        String s16 = code.substring(i + 1, t);
                        if (s16.isEmpty()) {
                            sb.append(ch);
                        } else {
                            int val16 = Integer.parseInt(s16, 16);
                            sb.append((char) val16);
                        }
                        i = t - 1;
                        slash = false;
                        break;
                    case '$':
                    case '"':
                    default:
                        slash = false;
                        sb.append(ch);
                        break;
                }
            } else {
                switch(ch) {
                    case '\\':
                        slash = true;
                        break;
                    case '$':
                        int k = i + 1;
                        boolean done = false;
                        int opened = 0;
                        int complex = 0;
                        if (k < codeLength) {
                            char first = code.charAt(k);
                            if (TokenizeGrammarUtils.isEngLetter(first) || first == '_') {
                                k++;
                                done = true;
                                for (; i < codeLength; k++) {
                                    if (k < codeLength) {
                                        first = code.charAt(k);
                                        if (Character.isDigit(first) || TokenizeGrammarUtils.isEngLetter(first) || first == '_') {
                                        // nop
                                        } else if (complex == 1 && TokenizeGrammarUtils.isVariableChar(first) && code.charAt(k - 1) == '[') {
                                        // nop
                                        } else if (complex == 0 && first == '[') {
                                            opened++;
                                            complex = 1;
                                        } else if (complex == 1 && opened != 0 && first == ']') {
                                            opened--;
                                            if (opened <= 0) {
                                                k++;
                                                break;
                                            }
                                        } else if (complex == 0 && first == '-') {
                                            if (k + 1 < codeLength && code.charAt(k + 1) == '>') {
                                                k++;
                                                complex = 2;
                                            } else
                                                break;
                                        } else
                                            break;
                                    } else
                                        break;
                                }
                            }
                        }
                        if (done) {
                            if (opened != 0)
                                throw new ParseException(Messages.ERR_PARSE_UNEXPECTED_END_OF_STRING.fetch(), new TraceInfo(context, startLine, 0, pos, 0));
                            String s = code.substring(i, k);
                            segments.add(new StringExprToken.Segment(sb.length(), sb.length() + s.length(), true));
                            sb.append(s);
                        } else
                            sb.append(ch);
                        i = k - 1;
                        break;
                    default:
                        sb.append(ch);
                }
            }
        }
    }
    if (ch_quote != quote || slash) {
        throw new ParseException(Messages.ERR_PARSE_UNEXPECTED_END_OF_STRING.fetch(), new TraceInfo(context, currentLine, currentLine, pos, pos));
    }
    TokenMeta meta = buildMeta(startPosition + 1, startLine);
    meta.setStartIndex(startIndex - 1);
    if (quote == StringExprToken.Quote.DOC) {
        meta.setEndIndex(currentPosition + 3);
    } else {
        meta.setEndIndex(currentPosition + 1);
    }
    meta.setWord(sb.toString());
    StringExprToken expr = new StringExprToken(meta, quote);
    expr.setSegments(segments);
    return expr;
}
Also used : ArrayList(java.util.ArrayList) TraceInfo(php.runtime.env.TraceInfo) StringExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StringExprToken) ParseException(php.runtime.exceptions.ParseException)

Example 15 with TraceInfo

use of php.runtime.env.TraceInfo in project jphp by jphp-compiler.

the class ObjectMemory method refOfIndex.

@Override
public Memory refOfIndex(final TraceInfo trace, final Memory index) {
    if (value instanceof ArrayAccess) {
        return new ReferenceMemory() {

            @Override
            public Memory assign(Memory memory) {
                Environment env = ObjectMemory.this.value.getEnvironment();
                if (env != null && trace != null) {
                    ArrayAccess array = (ArrayAccess) ObjectMemory.this.value;
                    Memory[] args = new Memory[] { index, memory };
                    env.pushCall(ObjectMemory.this.value, "offsetSet", args);
                    try {
                        array.offsetSet(env, args);
                    } finally {
                        env.popCall();
                    }
                } else
                    invalidUseAsArray(trace);
                return memory;
            }

            @Override
            public Memory assignRef(Memory reference) {
                return assign(reference);
            }

            @Override
            public Memory assign(long memory) {
                return assign(LongMemory.valueOf(memory));
            }

            @Override
            public Memory assign(String memory) {
                return assign(StringMemory.valueOf(memory));
            }

            @Override
            public Memory assign(boolean memory) {
                return assign(TrueMemory.valueOf(memory));
            }

            @Override
            public Memory assign(double memory) {
                return assign(DoubleMemory.valueOf(memory));
            }

            @Override
            public Memory assignConcat(Memory memory) {
                return assign(toValue().concat(memory));
            }

            @Override
            public Memory assignConcat(long memory) {
                return assign(toValue().concat(memory));
            }

            @Override
            public Memory assignConcat(double memory) {
                return assign(toValue().concat(memory));
            }

            @Override
            public Memory assignConcat(boolean memory) {
                return assign(toValue().concat(memory));
            }

            @Override
            public Memory assignConcat(String memory) {
                return assign(toValue().concat(memory));
            }

            @Override
            public Memory assignPlus(Memory memory) {
                setValue(toValue());
                return super.assignPlus(memory);
            }

            @Override
            public Memory assignPlus(long memory) {
                setValue(toValue());
                return super.assignPlus(memory);
            }

            @Override
            public Memory assignPlus(double memory) {
                setValue(toValue());
                return super.assignPlus(memory);
            }

            @Override
            public Memory assignPlus(boolean memory) {
                setValue(toValue());
                return super.assignPlus(memory);
            }

            @Override
            public Memory assignPlus(String memory) {
                setValue(toValue());
                return super.assignPlus(memory);
            }

            @Override
            public Memory assignPlusRight(Memory memory) {
                setValue(toValue());
                return super.assignPlusRight(memory);
            }

            @Override
            public Memory assignMinus(Memory memory) {
                setValue(toValue());
                return super.assignMinus(memory);
            }

            @Override
            public Memory assignMinus(long memory) {
                setValue(toValue());
                return super.assignMinus(memory);
            }

            @Override
            public Memory assignMinus(double memory) {
                setValue(toValue());
                return super.assignMinus(memory);
            }

            @Override
            public Memory assignMinus(boolean memory) {
                setValue(toValue());
                return super.assignMinus(memory);
            }

            @Override
            public Memory assignMinus(String memory) {
                setValue(toValue());
                return super.assignMinus(memory);
            }

            @Override
            public Memory assignMinusRight(Memory memory) {
                setValue(toValue());
                return super.assignMinusRight(memory);
            }

            @Override
            public Memory assignMul(Memory memory) {
                setValue(toValue());
                return super.assignMul(memory);
            }

            @Override
            public Memory assignMul(long memory) {
                setValue(toValue());
                return super.assignMul(memory);
            }

            @Override
            public Memory assignMul(double memory) {
                setValue(toValue());
                return super.assignMul(memory);
            }

            @Override
            public Memory assignMul(boolean memory) {
                setValue(toValue());
                return super.assignMul(memory);
            }

            @Override
            public Memory assignMul(String memory) {
                setValue(toValue());
                return super.assignMul(memory);
            }

            @Override
            public Memory assignMulRight(Memory memory) {
                setValue(toValue());
                return super.assignMulRight(memory);
            }

            @Override
            public Memory assignDiv(Memory memory) {
                setValue(toValue());
                return super.assignDiv(memory);
            }

            @Override
            public Memory assignDiv(long memory) {
                setValue(toValue());
                return super.assignDiv(memory);
            }

            @Override
            public Memory assignDiv(double memory) {
                setValue(toValue());
                return super.assignDiv(memory);
            }

            @Override
            public Memory assignDiv(boolean memory) {
                setValue(toValue());
                return super.assignDiv(memory);
            }

            @Override
            public Memory assignDiv(String memory) {
                setValue(toValue());
                return super.assignDiv(memory);
            }

            @Override
            public Memory assignDivRight(Memory memory) {
                setValue(toValue());
                return super.assignDivRight(memory);
            }

            @Override
            public Memory assignMod(Memory memory) {
                setValue(toValue());
                return super.assignMod(memory);
            }

            @Override
            public Memory assignMod(long memory) {
                setValue(toValue());
                return super.assignMod(memory);
            }

            @Override
            public Memory assignMod(double memory) {
                setValue(toValue());
                return super.assignMod(memory);
            }

            @Override
            public Memory assignMod(boolean memory) {
                setValue(toValue());
                return super.assignMod(memory);
            }

            @Override
            public Memory assignMod(String memory) {
                setValue(toValue());
                return super.assignMod(memory);
            }

            @Override
            public Memory assignModRight(Memory memory) {
                setValue(toValue());
                return super.assignModRight(memory);
            }

            @Override
            public Memory assignBitShr(Memory memory) {
                setValue(toValue());
                return super.assignBitShr(memory);
            }

            @Override
            public Memory assignBitShr(long memory) {
                setValue(toValue());
                return super.assignBitShr(memory);
            }

            @Override
            public Memory assignBitShr(double memory) {
                setValue(toValue());
                return super.assignBitShr(memory);
            }

            @Override
            public Memory assignBitShr(boolean memory) {
                setValue(toValue());
                return super.assignBitShr(memory);
            }

            @Override
            public Memory assignBitShr(String memory) {
                setValue(toValue());
                return super.assignBitShr(memory);
            }

            @Override
            public Memory assignBitShrRight(Memory memory) {
                setValue(toValue());
                return super.assignBitShrRight(memory);
            }

            @Override
            public Memory assignBitShl(Memory memory) {
                setValue(toValue());
                return super.assignBitShl(memory);
            }

            @Override
            public Memory assignBitShl(long memory) {
                setValue(toValue());
                return super.assignBitShl(memory);
            }

            @Override
            public Memory assignBitShl(double memory) {
                setValue(toValue());
                return super.assignBitShl(memory);
            }

            @Override
            public Memory assignBitShl(boolean memory) {
                setValue(toValue());
                return super.assignBitShl(memory);
            }

            @Override
            public Memory assignBitShl(String memory) {
                setValue(toValue());
                return super.assignBitShl(memory);
            }

            @Override
            public Memory assignBitShlRight(Memory memory) {
                setValue(toValue());
                return super.assignBitShlRight(memory);
            }

            @Override
            public Memory assignBitAnd(Memory memory) {
                setValue(toValue());
                return super.assignBitAnd(memory);
            }

            @Override
            public Memory assignBitAnd(long memory) {
                setValue(toValue());
                return super.assignBitAnd(memory);
            }

            @Override
            public Memory assignBitAnd(double memory) {
                setValue(toValue());
                return super.assignBitAnd(memory);
            }

            @Override
            public Memory assignBitAnd(boolean memory) {
                setValue(toValue());
                return super.assignBitAnd(memory);
            }

            @Override
            public Memory assignBitAnd(String memory) {
                setValue(toValue());
                return super.assignBitAnd(memory);
            }

            @Override
            public Memory assignBitAndRight(Memory memory) {
                setValue(toValue());
                return super.assignBitAndRight(memory);
            }

            @Override
            public Memory assignBitOr(Memory memory) {
                setValue(toValue());
                return super.assignBitOr(memory);
            }

            @Override
            public Memory assignBitOr(long memory) {
                setValue(toValue());
                return super.assignBitOr(memory);
            }

            @Override
            public Memory assignBitOr(double memory) {
                setValue(toValue());
                return super.assignBitOr(memory);
            }

            @Override
            public Memory assignBitOr(boolean memory) {
                setValue(toValue());
                return super.assignBitOr(memory);
            }

            @Override
            public Memory assignBitOr(String memory) {
                setValue(toValue());
                return super.assignBitOr(memory);
            }

            @Override
            public Memory assignBitOrRight(Memory memory) {
                setValue(toValue());
                return super.assignBitOrRight(memory);
            }

            @Override
            public Memory assignBitXor(Memory memory) {
                setValue(toValue());
                return super.assignBitXor(memory);
            }

            @Override
            public Memory assignBitXor(long memory) {
                setValue(toValue());
                return super.assignBitXor(memory);
            }

            @Override
            public Memory assignBitXor(double memory) {
                setValue(toValue());
                return super.assignBitXor(memory);
            }

            @Override
            public Memory assignBitXor(boolean memory) {
                setValue(toValue());
                return super.assignBitXor(memory);
            }

            @Override
            public Memory assignBitXor(String memory) {
                setValue(toValue());
                return super.assignBitXor(memory);
            }

            @Override
            public Memory assignBitXorRight(Memory memory) {
                setValue(toValue());
                return super.assignBitXorRight(memory);
            }

            @Override
            public Memory toValue() {
                return ObjectMemory.this.valueOfIndex(trace, index);
            }

            @Override
            public ReferenceMemory getReference() {
                Memory ret = toValue();
                if (ret instanceof ReferenceMemory)
                    return (ReferenceMemory) ret;
                else
                    return new ReferenceMemory();
            }

            @Override
            public Memory toImmutable() {
                return toValue().toImmutable();
            }

            @Override
            public Memory inc() {
                return toValue().inc();
            }

            @Override
            public Memory dec() {
                return toValue().dec();
            }

            @Override
            public Memory valueOfIndex(TraceInfo trace, Memory index) {
                return toValue().valueOfIndex(trace, index);
            }

            @Override
            public Memory valueOfIndex(TraceInfo trace, long index) {
                return toValue().valueOfIndex(trace, index);
            }

            @Override
            public Memory valueOfIndex(TraceInfo trace, double index) {
                return toValue().valueOfIndex(trace, index);
            }

            @Override
            public Memory valueOfIndex(TraceInfo trace, String index) {
                return toValue().valueOfIndex(trace, index);
            }

            @Override
            public Memory valueOfIndex(TraceInfo trace, boolean index) {
                return toValue().valueOfIndex(trace, index);
            }

            @Override
            public Memory refOfPush(TraceInfo trace) {
                return toValue().refOfPush(trace);
            }

            @Override
            public Memory refOfIndexAsShortcut(TraceInfo trace, Memory index) {
                return toValue().refOfIndexAsShortcut(trace, index);
            }

            @Override
            public Memory refOfIndex(TraceInfo trace, Memory index) {
                return toValue().refOfIndex(trace, index);
            }

            @Override
            public Memory refOfIndex(TraceInfo trace, long index) {
                return toValue().refOfIndex(trace, index);
            }

            @Override
            public Memory refOfIndex(TraceInfo trace, double index) {
                return toValue().refOfIndex(trace, index);
            }

            @Override
            public Memory refOfIndex(TraceInfo trace, String index) {
                return toValue().refOfIndex(trace, index);
            }

            @Override
            public Memory refOfIndex(TraceInfo trace, boolean index) {
                return toValue().refOfIndex(trace, index);
            }

            @Override
            public void unsetOfIndex(TraceInfo trace, Memory index) {
                toValue().unsetOfIndex(trace, index);
            }

            @Override
            public Memory issetOfIndex(TraceInfo trace, Memory index) {
                return toValue().issetOfIndex(trace, index);
            }

            @Override
            public Memory emptyOfIndex(TraceInfo trace, Memory index) {
                return toValue().emptyOfIndex(trace, index);
            }
        };
    } else {
        invalidUseAsArray(trace);
        return new ReferenceMemory();
    }
}
Also used : ArrayAccess(php.runtime.lang.spl.ArrayAccess) Memory(php.runtime.Memory) Environment(php.runtime.env.Environment) TraceInfo(php.runtime.env.TraceInfo)

Aggregations

TraceInfo (php.runtime.env.TraceInfo)15 Memory (php.runtime.Memory)10 ObjectMemory (php.runtime.memory.ObjectMemory)4 StringMemory (php.runtime.memory.StringMemory)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Environment (php.runtime.env.Environment)3 ParseException (php.runtime.exceptions.ParseException)3 ArrayList (java.util.ArrayList)2 Tokenizer (org.develnext.jphp.core.tokenizer.Tokenizer)2 CompileFunction (php.runtime.ext.support.compile.CompileFunction)2 Invoker (php.runtime.invoke.Invoker)2 IObject (php.runtime.lang.IObject)2 ArrayMemory (php.runtime.memory.ArrayMemory)2 LongMemory (php.runtime.memory.LongMemory)2 Constructor (java.lang.reflect.Constructor)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 MethodNodeImpl (org.develnext.jphp.core.compiler.jvm.node.MethodNodeImpl)1 SyntaxAnalyzer (org.develnext.jphp.core.syntax.SyntaxAnalyzer)1 TokenMeta (org.develnext.jphp.core.tokenizer.TokenMeta)1 BreakToken (org.develnext.jphp.core.tokenizer.token.BreakToken)1