Package soot

Examples of soot.Value


        Local bufferLocal = Jimple.v().newLocal("buffer",
                ArrayType.v(PtolemyUtilities.tokenType, 1));
        body.getLocals().add(bufferLocal);

        // The first argument is always the channel.
        Value channelValue = expr.getArg(0);

        // We have to repeat for all of the remote types.
        Set typeSet = _getConnectedTypeList(port);

        for (Iterator types = typeSet.iterator(); types.hasNext();) {
            ptolemy.data.type.Type type = (ptolemy.data.type.Type) types.next();
            Local typeLocal = null;

            //   if (!port.getType().equals(type)) {
            typeLocal = PtolemyUtilities.buildConstantTypeLocal(body, stmt,
                    type);

            // }
            _getBuffer(_modelClass, body, stmt, port, port.getType(),
                    bufferLocal, _portToTypeNameToBufferField);

            // A local of type token
            Local tokenLocal = Jimple.v().newLocal("tokenLocal",
                    PtolemyUtilities.tokenType);
            body.getLocals().add(tokenLocal);

            // A local of the appropriate type to store in the
            // buffer.
            Local outputTokenLocal = Jimple.v().newLocal("outputTokenLocal",
                    PtolemyUtilities.getSootTypeForTokenType(type));
            body.getLocals().add(outputTokenLocal);

            // If we are calling with just a channel, then write the value.
            if (expr.getArgCount() == 2) {
                Local sendTokenLocal = (Local) expr.getArg(1);

                // Replace the put() with an array write.
                body.getUnits().insertBefore(
                        _createBufferStoreInstructions(bufferLocal,
                                channelValue, sendTokenLocal, typeLocal,
                                tokenLocal, outputTokenLocal), stmt);
            } else {
                Local sendArrayLocal = (Local) expr.getArg(1);

                /*                Jimple.v().newLocal("sendArray",
                 ArrayType.v(PtolemyUtilities.tokenType, 1));
                 body.getLocals().add(sendArrayLocal);

                 // We must send an array of tokens.
                 body.getUnits().insertBefore(
                 Jimple.v().newAssignStmt(
                 sendArrayLocal,
                 expr.getArg(1)),
                 stmt);*/
                Value countValue = expr.getArg(2);

                Local sendTokenLocal = Jimple.v().newLocal("sendToken",
                        PtolemyUtilities.tokenType);
                body.getLocals().add(sendTokenLocal);

View Full Code Here


        Local bufferLocal = Jimple.v().newLocal("buffer",
                ArrayType.v(PtolemyUtilities.tokenType, 1));
        body.getLocals().add(bufferLocal);

        // The first argument is always the channel.
        Value channelValue = expr.getArg(0);

        // We have to repeat for all of the remote types.
        Set typeSet = _getConnectedTypeListInside(port);

        for (Iterator types = typeSet.iterator(); types.hasNext();) {
            ptolemy.data.type.Type type = (ptolemy.data.type.Type) types.next();
            Local typeLocal = null;

            //   if (!port.getType().equals(type)) {
            typeLocal = PtolemyUtilities.buildConstantTypeLocal(body, stmt,
                    type);

            // }
            _getBuffer(_modelClass, body, stmt, port, port.getType(),
                    bufferLocal, _portToTypeNameToInsideBufferField);

            // A local of type token
            Local tokenLocal = Jimple.v().newLocal("tokenLocal",
                    PtolemyUtilities.tokenType);
            body.getLocals().add(tokenLocal);

            // A local of the appropriate type to store in the
            // buffer.
            Local outputTokenLocal = Jimple.v().newLocal("outputTokenLocal",
                    PtolemyUtilities.getSootTypeForTokenType(type));
            body.getLocals().add(outputTokenLocal);

            // If we are calling with just a channel, then write the value.
            if (expr.getArgCount() == 2) {
                Local sendTokenLocal = (Local) expr.getArg(1);

                // Replace the put() with an array write.
                body.getUnits().insertBefore(
                        _createBufferStoreInstructions(bufferLocal,
                                channelValue, sendTokenLocal, typeLocal,
                                tokenLocal, outputTokenLocal), stmt);
            } else {
                Local sendArrayLocal = (Local) expr.getArg(1);

                /*                Jimple.v().newLocal("sendArray",
                 ArrayType.v(PtolemyUtilities.tokenType, 1));
                 body.getLocals().add(sendArrayLocal);

                 // We must send an array of tokens.
                 body.getUnits().insertBefore(
                 Jimple.v().newAssignStmt(
                 sendArrayLocal,
                 expr.getArg(1)),
                 stmt);*/
                Value countValue = expr.getArg(2);

                Local sendTokenLocal = Jimple.v().newLocal("sendToken",
                        PtolemyUtilities.tokenType);
                body.getLocals().add(sendTokenLocal);

View Full Code Here

                if (!unit.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = unit.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                    if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getPortMethod.getSubSignature())) {
                        if (_debug) {
                            System.out.println("replacing getPort in " + unit);
                        }

                        // Inline calls to getPort(arg) when
                        // arg is a string that can be
                        // statically evaluated.
                        Value nameValue = r.getArg(0);

                        if (Evaluator.isValueConstantValued(nameValue)) {
                            StringConstant nameConstant = (StringConstant) Evaluator
                                    .getConstantValueOf(nameValue);
                            String name = nameConstant.value;

                            // perform type analysis to determine what the
                            // type of the base is.
                            Local baseLocal = (Local) r.getBase();
                            Value newFieldRef = _createPortField(baseLocal,
                                    name, unit, localDefs);

                            if (unit instanceof AssignStmt) {
                                box.setValue(newFieldRef);
                            } else {
View Full Code Here

            LocalDefs localDefs) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof CastExpr) {
                return _getFieldDef((Local) ((CastExpr) value).getOp(), stmt,
                        localDefs);
            } else if (value instanceof FieldRef) {
View Full Code Here

                if (!unit.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = unit.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                    if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getContainerMethod
                                    .getSubSignature())) {
                        Value newFieldRef = _getContainerMethodReplacementFieldRef(
                                theClass, (Local) r.getBase(), body, unit,
                                localDefs);
                        box.setValue(newFieldRef);

                        if (_debug) {
                            System.out.println("replacing " + unit);
                        }
                    } else if (r.getMethod().equals(
                            PtolemyUtilities.toplevelMethod)) {
                        // Replace with reference to the toplevel
                        Value newFieldRef = getLocalReferenceForEntity(_model,
                                theClass, body.getThisLocal(), body, unit,
                                _options);
                        box.setValue(newFieldRef);

                        if (_debug) {
                            System.out.println("replacing " + unit);
                        }
                    } else if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getEntityMethod.getSubSignature())) {
                        Value nameValue = r.getArg(0);

                        if (Evaluator.isValueConstantValued(nameValue)) {
                            StringConstant nameConstant = (StringConstant) Evaluator
                                    .getConstantValueOf(nameValue);
                            String name = nameConstant.value;

                            if (_debug) {
                                System.out.println("replacing " + unit);
                            }

                            Value newFieldRef = _getEntityMethodReplacementValue(
                                    theClass, (Local) r.getBase(), name, body,
                                    unit, localDefs);
                            box.setValue(newFieldRef);

                            if (_debug) {
View Full Code Here

            LocalDefs localDefs) {
        List definitionList = localDefs.getDefsOfAt(local, location);

        if (definitionList.size() == 1) {
            DefinitionStmt stmt = (DefinitionStmt) definitionList.get(0);
            Value value = stmt.getRightOp();

            if (value instanceof CastExpr) {
                return _getFieldDef((Local) ((CastExpr) value).getOp(), stmt,
                        localDefs);
            } else if (value instanceof FieldRef) {
View Full Code Here

                if (!stmt.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = stmt.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr expr = (InstanceInvokeExpr) value;

                    if (expr.getMethod().equals(mainStartRunMethod)) {
View Full Code Here

    }
    return ret;
  }
 
  private boolean isLastExit(ExitMonitorStmt exit, int index, List<Unit> units){
    Value op = exit.getOp();
    Local op_local = (Local) op;
    for(int j = index + 1; j < units.size(); ++j){
      Unit curr = units.get(j);
      if(curr instanceof EnterMonitorStmt){
        return true;
View Full Code Here

      checkException();
    }
  }

  private void caseDefinitionStmt(DefinitionStmt arg0){
    Value left_op = arg0.getLeftOp();
    Value right_op = arg0.getRightOp();
    Type left_op_type = left_op.getType();
    OpenCLType ocl_left_op_type = new OpenCLType(left_op_type);

    //if the left op is a field ref or array ref we use the setter
    if(left_op instanceof FieldRef || left_op instanceof ArrayRef){
      m_valueSwitch.setLhs();
      left_op.apply(m_valueSwitch);
      m_valueSwitch.setRhs();
      right_op.apply(m_valueSwitch);
      m_output.append(", exception);\n");
      if(m_valueSwitch.getCheckException()){
        checkException();
      }
      m_valueSwitch.clearLhsRhs();
    }
    //if the right op is a field ref or array ref we use the getter
    else if(right_op instanceof FieldRef || right_op instanceof ArrayRef){
      m_valueSwitch.setLhs();
      left_op.apply(m_valueSwitch);
      m_output.append(" = ");
      m_valueSwitch.setRhs();
      right_op.apply(m_valueSwitch);
      m_output.append(";\n");
      if(m_valueSwitch.getCheckException()){
        checkException();
      }
      m_valueSwitch.clearLhsRhs();
View Full Code Here

   
  }

  public void caseThrowStmt(ThrowStmt arg0) {
    m_output.append(" *exception = ");
    Value op = arg0.getOp();
    op.apply(m_valueSwitch);
    m_output.append(";\n");
    if(m_sootMethod.isSynchronized()){
      m_output.append("org_trifort_exitMonitorMem(mem, old);\n");
    }
    m_output.append("return");
View Full Code Here

TOP

Related Classes of soot.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.